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 task's priority is used in scheduling?
Which are the different segments of memory?
What is the difference between session and entity beans?
What are the difference between RMI and CORBA?
What is chat area? Explain.
What do you need to set-up a cluster with jboss?
Which characters may be used as the second character of an identifier, but not as the first character of an identifier?
What if the static modifier is removed from the signature of the main method?
What is the difference between a static and a non-static inner class?
What are the services in RMI ?
How would you reatach detached objects to a session when the same object has already been loaded into the session?
Describe, in general, how java's garbage collector works?
What are JTA/JTS and how they used by client?
How would you create a button with rounded edges?
What is the relationship between an event-listener interface and an event-adapter class?