Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

can a static method be overridden

Answer Posted / karteek

Hi, Srinivas.....in the above program posted by Aswini...I
think main() method is overridden....right?.....then we can
say static methods can be overridden....

Eg:

class Parent
{
public static void myStaticMethod()
{
System.out.println("A");
}

public void myInstanceMethod()
{
System.out.println("B");
}
}

public class Child extends Parent
{
public static void myStaticMethod()
{
System.out.println("C");
}

public void myInstanceMethod()
{
System.out.println("D");
}

public static void main(String[] args)
{
Parent o1 = new Parent();

Child o3 = new Child();

Parent.myStaticMethod(); // A
Child.myStaticMethod(); // C

o1.myStaticMethod(); // A
o1.myInstanceMethod(); // B


o3.myStaticMethod(); // C
o3.myInstanceMethod(); // D


}
}

In the above program myStaticMethod() is
overridden.....which is a static method.....

Is This Answer Correct ?    10 Yes 16 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between long.class and long.type?

1180


What is meant by method chaining?

1207


Explain how will the struts know which action class to call when you submit a form?

1015


Why are my checkboxes not being set from on to off?

1185


What is the relation between the infobus and rmi?

1067


What is the diffrence between a local-tx-datasource and a xa-datasource?

1110


Difference between DurableSubscription and non- DurableSubscription?

2238


Why a client should be multithreading? Explain.

1136


What must a class do to implement an interface?

1285


What is the difference between the session.update() method and the session.lock() method?

1088


What are the pros and cons of detached objects?

1042


Explain about local interfaces.

1121


Explain the difference between object state and behavior?

1117


Should synchronization primitives be used on bean methods?

1119


wahts is mean by dynavalidatorform in struts/

2122