Answer Posted / ramandeep
Yes you can override static methods..
see the following two classes :
public class Super
{
public static void main(String args[])
{
}
public static void m1()
{
System.out.println("superclass");
}
}
public class Sub extends Super
{
public static void main(String args[])
{
Super superWalaObj = new Sub();
superWalaObj.m1();
Sub subWalaObj = new Sub();
subWalaObj.m1();
}
public static void m1()
{
System.out.println("subclass");
}
}
Running this gives the following output :
superclass
subclass
Which explains the behaviour itself.
By overriding the static methods we are forcing them to
behave as non-static methods when used with object.
However, making a call directly to the staticy. method will
call the method belonging to that class only
| Is This Answer Correct ? | 7 Yes | 1 No |
Post New Answer View All Answers
How would you reatach detached objects to a session when the same object has already been loaded into the session?
How are the elements of a cardlayout organized?
Explain the advantages and disadvantages of detached objects.
what are getters and setters in Java with examples?
How will you pass parameters in RMI? Why do you serialize?
What are the design considerations while making a choice between using interface and abstract class?
What are the types of scaling?
What are the different algorithms used for clustering?
What are the steps to write p-to-p model application?
how to use debug in my elipse to solve problems that exist in my project
How would you detect a keypress in a jcombobox?
Which class is the immediate superclass of the menucomponent class?
Describe responsibilities of Activator?
Is there a guarantee of uniqueness for entity beans?
What you mean by COM and DCOM?