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 relationship between local interfaces and container-managed relationships?
What is clustering? What are the different algorithms used for clustering?
How would you detect a keypress in a jcombobox?
Java is fully object oriented languages or not?
What must a class do to implement an interface?
In our urls and in the text of the buttons we have comma. Its causing an error. Is there a way to change the delimiting character for the menu arguments?
what are the activation groupworks?
Is a class a subclass of itself?
Why do threads block on i/o?
What is the relationship between the canvas class and the graphics class?
What is the difference between a static and a non-static inner class?
What do you know about seam?
What is the difference between RMI and Corba?
What are JTA/JTS and how they used by client?
Explain RMI Architecture?