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 message driven beam?
What is the purpose of the notifyall() method?
What are the pros and cons of detached objects?
What must a class do to implement an interface?
which book is better for jdbc ,servlets and jsp
What is the difference between the session.get() method and the session.load() method?
difference between ejb,struts,hibernate,spring and jsp
Can I run seam with jdk 1.4 and earlier?
What are the types of scaling?
What are the design considerations while making a choice between using interface and abstract class?
What is the immediate superclass of the applet class?
What is the difference between the ‘font’ and ‘fontmetrics’ class?
What is an abstract method?
Why doesn’t the focus feature on the tag work in every circumstance?
the same information whether it will connect to the database or it will be used previous information?