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
What is the difference between ear, jar and war file?
What is colon_pkg_prefixes and what is its use?
what is meant by JRMP?
Describe responsibilities of Activator?
What are the call back methods in entity bean?
How would you detect a keypress in a jcombobox?
Define prototype?
Difference between loadclass and class.forname?
What is the difference between long.class and long.type?
Why are component architectures useful?
When is the best time to validate input?
how i secure my site with the https protocol.what are the steps?
What state does a thread enter when it terminates its processing?
Is there a guarantee of uniqueness for entity beans?
What value does readline() return when it has reached the end of a file?