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 the RMI and Socket?
How messaging services are done, before release of JMS?
For which statements does it make sense to use a label?
What are the different algorithms used for clustering?
What is prototype?
Are enterprise beans allowed to use thread.sleep()?
Is the infobus client side only?
What is glasgow?
What is ripple effect?
Is the ternary operator written x : y ? Z or x ? Y : z ?
Why use POJO when I can use hashmap
A user of a web application sees a jsessionid argument in the URL whenever a resource is accessed. What does this mean? a. The form must have the field jsessionid b. URL rewriting is used as the session method c. Cookies are used for managing sessions
Explain how will the struts know which action class to call when you submit a form?
What is the infobus?
What are local interfaces? Describe.