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 / vinay

Making things more clear, how static and non-static method
behaves
public class Super
{

public static void m1()
{
System.out.println("superclass static ");
}
public void m2()
{
System.out.println("superclass nonstatic ");
}
}

public class Sub extends Super
{
public static void main(String args[])
{
Super superWalaObj = new Sub();
superWalaObj.m1();
superWalaObj.m2();

Sub subWalaObj = new Sub();
subWalaObj.m1();
subWalaObj.m2();
}

public static void m1()
{
System.out.println("subclass static ");
}
public void m2()
{
System.out.println("subclass nonstatic ");
}
}


Result:
superclass static
subclass nonstatic
subclass static
subclass nonstatic

Note: The first output is not "subclass static" as with non
static methods.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is the session factory thread safe?

1175


What are the different approaches to represent an inheritance hierarchy?

1073


If I wanted to use a solarisui for just a jtabbedpane, and the metal ui for everything else, how would I do that?

1067


What is ripple effect?

1079


What are externizable interface?

1065


What is the purpose of the wait(), notify(), and notifyall() methods?

1031


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

1105


wahts is mean by dynavalidatorform in struts/

2080


Do you think that java should have had pointers?

1058


When a thread blocks on i/o?

1099


What method is invoked to cause an object to begin executing as a separate thread?

1040


which type of objects reference will be given to client?

2485


Why a component architecture for the java platform?

1217


How a component can be placed on Windows?

2857


Why is actionform a base class rather than an interface?

1064