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

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

1024


What is the difference between a menuitem and a checkboxmenuitem?

1053


A user of a web application sees a jsessionid argument in the URL whenever a resource is accessed. What does this mean? a. The form must have the field jsessionid b. URL rewriting is used as the session method c. Cookies are used for managing sessions

2207


how do you Handle Front End Application data against DB with example?

1939


What is Stream Tokenizer?

2195


What is TL and its use?

2419


Define the remote object implementation?

2439


Why use a datasource when you can directly specify a connection details? (in a J2EE application)

4202


How would you detect a keypress in a jcombobox?

1103


What is the difference between static and non-static with examples?

1882


What is aop(assepct oriented programing)?

1011


Name three subclasses of the component class?

1065


Why a component architecture for the java platform?

1145


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?

1132


Which class is the immediate superclass of the menucomponent class?

1170