can a static method be overridden
Answer Posted / mayank
only static method in a subclass can over ride the static
method in the parent class.
for example
public class A {
public static int display(){
System.out.println("i an in A");
return 1;
}
}
public class B extends A{
public static int display(){
System.out.println("i an in B");
return 1;
}
/*public int display(){
}*/
}
will work fine. but if the subclass tries to override parent
class static method with a non static method it generates
compilation error.
for eg
public class B extends A{
/* public static int display(){
System.out.println("i an in B");
return 1;
}*/
public int display(){
}
}
the above code will result in compilation error.
| Is This Answer Correct ? | 5 Yes | 5 No |
Post New Answer View All Answers
Difference between loadclass and class.forname?
How to determine SGA site?
What are transaction attributes?
Java is fully object oriented languages or not?
Can I map more than one table in a cmp?
What are the different methods of identifying an object?
What is RMI and what are the services in RMI?
What is the difference between the session.get() method and the session.load() method?
Describe activation process?
What is the purpose of the notify() method?
What you mean by COM and DCOM?
What do you know about seam?
difference between ejb,struts,hibernate,spring and jsp
What restrictions are placed on the values of each case of a switch statement?
Difference between hashmap and hashtable?