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
Explain what is synchronization?
Is “abc” a primitive value?
How can I avoid validating a form before data is entered?
Why does the tag url-encode javascript and mailto links?
What is scalable, portability in the view of J2EE?
What are the different algorithms used for clustering?
Which class is the immediate superclass of the menucomponent class?
What modifiers may be used with an interface declaration?
What are the different class loaders used by jvm?
Is jvm a overhead?
What is metaspace?
What is the difference between RMI registry and OS Agent?
How a component can be placed on Windows?
When a thread blocks on i/o, what state does it enter?
What are the types of scaling?