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 are transaction attributes?

1045


What do you mean by Socket Programming?

1033


Do you think that java should have had pointers?

1009


What are JTA/JTS and how they used by client?

2175


Where we can write Rmi registry in the code, without having to write it at the command prompt?

2731


What are callback interfaces?

1051


What modifiers may be used with an interface declaration?

1073


Can you give me a simple example of using the requiredif validator rule?

1067


Should synchronization primitives be used on bean methods?

1004


In our urls and in the text of the buttons we have comma. Its causing an error. Is there a way to change the delimiting character for the menu arguments?

1121


What is a class loader? What are the different class loaders used by jvm?

1054


How to pass parameters in RMI?

2222


Which textcomponent method is used to set a textcomponent to the read-only state?

1063


Name three component subclasses that support painting?

1020


What is scalable, portability in the view of J2EE?

2474