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
What is the difference between session and entity beans?
Name the class that is used to bind the server object with RMI Registry?
What is the purpose of the wait() method?
What is the relation between the infobus and rmi?
whats is mean by tiles in struts
What classes of exceptions may be caught by a catch clause?
Which javutil classes and interfaces support event handling?
How can I avoid validating a form before data is entered?
What is difference between object state and behavior?
Explain about local interfaces.
Are there books about seam?
In RMI, inorder to sent the stub reference to the client, is we have to load the server object first into the memory or can we directly sent reference to the client?
What is threadfactory?
What is clustering? What are the different algorithms used for clustering?
Describe, in general, how java's garbage collector works?