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 characters may be used as the second character of an identifier, but not as the first character of an identifier?

1036


difference between  ejb,struts,hibernate,spring and jsp

2844


What are the oops concept?

1056


Is there a guarantee of uniqueness for entity beans?

995


Difference between loadclass and class.forname?

1038


How task's priority is used in scheduling?

2285


What is a class loader?

1857


What is a tasks priority and how is it used in scheduling?

1045


What is the map interface?

1109


What is meant by method chaining?

1132


Why is actionform a base class rather than an interface?

1048


If we opened Windows Internet Explorer 4 times, does it starts 4 processes or 4 threads?

2199


What are the benefits of detached objects?

1043


Explain about thread synchronization inside a monitor?

2526


Difference between DurableSubscription and non- DurableSubscription?

2179