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
Which textcomponent method is used to set a textcomponent to the read-only state?
What is the difference between a menuitem and a checkboxmenuitem?
When is the best time to validate input?
How messaging services are done, before release of JMS?
What are externizable interface?
why static class in java
A user of a web application sees a jsessionid argument in the URL whenever a resource is accessed. What does this mean? a. The form must have the field jsessionid b. URL rewriting is used as the session method c. Cookies are used for managing sessions
Will the general public have access to the infobus apis?
What is the relationship between an event-listener interface and an event-adapter class?
What are the different approaches to represent an inheritance hierarchy?
Explain the steps in details to load the server object dynamically?
How database connectivity in XML is achieved?
Explain about local interfaces.
What is the difference between the string and stringbuffer classes?
Difference between loadclass and class.forname?