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 permgen or permanent generation?
Name the class that is used to bind the server object with RMI Registry?
the same information whether it will connect to the database or it will be used previous information?
Difference between new operator and class.forname().newinstance()?
Why a client should be multithreading? Explain.
How is a java object message delivered to a non-java client?
how do you Handle Front End Application data against DB with example?
what are getters and setters in Java with examples?
we use MainFrame and using os390 for operating system with DB2 data base in IRAN and interest programing with java and use webspere for world wide,please help me where i should start?
what are the advantages of JTA over JTS?
Java is fully object oriented languages or not?
What are the oops concept?
What is the difference between static and non-static with examples?
What is aop(assepct oriented programing)?
What is the difference between session and entity beans?