can a static method be overridden

Answers were Sorted based on User's Feedback



can a static method be overridden ..

Answer / aswini de

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 b=a*a;
return b;
}

}

public class Test2 {
public static void main(String args[]){

}

public static int cal(int a,int b){
int c=a*b;
System.out.println("IN Super orerriden
methods:");
return c;
}

public void displayX(){
System.out.println("HI i am in Super");
}

}
my Sub Class is Test extends Test2 Class
Common static method is cal()

its run properly. No compile error , NO runtime error

Is This Answer Correct ?    4 Yes 38 No

Post New Answer

More Advanced Java Interview Questions

what we can't do in jdbc but can do hibernate?

3 Answers   Cap Gemini,


what is the Scope of Final Keyword in Java?

1 Answers   HCL,


What is meant by method chaining?

0 Answers  


What is the need of serialize?

2 Answers   Wipro,


Why is main purpose of XML?

5 Answers  






What are the high-level thread states?

1 Answers  


What are the JSP implicit objects ?

1 Answers   eMids,


Why use POJO when I can use hashmap

0 Answers   Infotech,


String is immutable.it is true String can be change to mutable How?

6 Answers   IBM, Professional Access, TCS,


What is a clone?

0 Answers  


What are the types of scaling?

0 Answers  


which type of objects reference will be given to client?

0 Answers  


Categories