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
Is a class a subclass of itself?
what are memory considerations of jsp compares to other web components?
How are commas used in the intialization and iteration parts of a for statement?
For which statements does it make sense to use a label?
What are the types of scaling?
What is the difference between java class and bean?
What is difference between object state and behavior?
What is the map interface?
Why are component architectures useful?
When is the best time to validate input?
How are the elements of a borderlayout organized?
Will the general public have access to the infobus apis?
Which javutil classes and interfaces support event handling?
Why a component architecture for the java platform?
What is a session? Can you share a session object between different theads?