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

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

1144


what is a portable component?

2022


What is the highest-level event class of the event-delegation model?

1106


Is “abc” a primitive value?

1121


What are callback interfaces?

1101


Is a class a subclass of itself?

1228


Difference between DurableSubscription and non- DurableSubscription?

2198


What modifiers may be used with an interface declaration?

1143


Describe, in general, how java's garbage collector works?

1039


What is glasgow?

1065


What is abstract schema?

1036


When a thread blocks on i/o, what state does it enter?

1097


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

2772


What is an abstract method?

1077


Do I have to use jsps with my application?

1027