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 abstract schema?
whats is mean by connectionpooling
what is a portable component?
What event results from the clicking of a button?
how i secure my site with the https protocol.what are the steps?
What is a policy?
Can I run seam outside of jboss as?
What is a class loader? What are the different class loaders used by jvm?
What is the difference between the font and fontmetrics classes?
What method is invoked to cause an object to begin executing as a separate thread?
What class is used to create Server side object ?
In inglish: How to convert jar to exe files? Em português: Como converter arquivos .jar para .exe?
What modifiers may be used with an inner class that is a member of an outer class?
What you mean by COM and DCOM?
What are transaction attributes?