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
Explain the advantages and disadvantages of detached objects.
Which javutil classes and interfaces support event handling?
Why are component architectures useful?
Is the session factory thread safe?
when A client sent a request to the server to open facebook page and close the browser after this request .at that time the same user do login by using a different browser then that session id will exist or not for the same client??
Name three subclasses of the component class?
wahts is mean by dynavalidatorform in struts/
Explain phantom read?
Explain about thread synchronization inside a monitor?
What is ioc concept?
What is the difference between ear, jar and war file?
What is the difference between long.class and long.type?
Is jvm a overhead?
what are the activation groupworks?
What are the steps to write p-to-p model application?