can a static method be overridden
Answer Posted / ravi ranjan
Yes a static method can be overridden
see following two classes
public class Test extends Test2{
public static void main(String args[]){
String str="";
int b=Test.cal(4);
System.out.println(b);
Test t =new Test();
t.displayX();
}
public static int cal(int a){
int c=a*a;
System.out.println("Hi I am Child" );
return c;
}
}
class Test2 {
public static void main(String args[]){
}
public static int cal(int a){
int c=a*a;
System.out.println(c);
return c;
}
public void displayX(){
System.out.println("HI i am in Super");
}
}
Compile this code there is no compile or run time error
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What is threadfactory?
Can I run seam outside of jboss as?
what is a non-repeatable read?
Explain the difference between object state and behavior?
What is the highest-level event class of the event-delegation model?
Why won’t the jvm terminate when I close all the application windows?
What is a session? Can you share a session object between different theads?
Will the general public have access to the infobus apis?
Name the class that is used to bind the server object with RMI Registry?
What are transaction attributes?
What is the purpose of the notifyall() method?
What is clustering? What are the different algorithms used for clustering?
Which characters may be used as the second character of an identifier, but not as the first character of an identifier?
Where can I find seam examples and documentation?
How are the elements of a borderlayout organized?