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 jboss?
How would you create a button with rounded edges?
What is meant by method chaining?
What do you need to set-up a cluster with jboss?
What is the difference between the font and fontmetrics classes?
Which component handles cluster communication in jboss?
Which class is the immediate superclass of the menucomponent class?
Explain about local interfaces.
How a component can be placed on Windows?
Is the session factory thread safe?
What is the purpose of the notify() method?
What is the difference between long.class and long.type?
What is the difference between system.out ,system.err and system.in?
Is “abc” a primitive value?
What are callback interfaces?