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
Do I have to use jsps with my application?
what is a portable component?
What do you need to set-up a cluster with jboss?
Are there books about seam?
How are the elements of a cardlayout organized?
What is local interface. How values will be passed?
int x=5,i=1,y=0; while(i<=5) { y=x++ + ++x; i=i+2; } System.out.println(x); System.out.println(y); System.out.println(i); How to solve this? Please explain!
What is the immediate superclass of the applet class?
What are the different approaches to represent an inheritance hierarchy?
Explain RMI Architecture?
How to implement dphibernate to activate lazy loading in Flex with java ?thanx in advance!
How would you create a button with rounded edges?
What are the pros and cons of detached objects?
How to determine SGA site?
Will the general public have access to the infobus apis?