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
Why a client should be multithreading? Explain.
What is TL and its use?
When is the best time to validate input?
what are getters and setters in Java with examples?
What is ioc concept & explain it?
why static class in java
Can I map more than one table in a cmp?
How are the elements of a cardlayout organized?
What is a policy?
what is handle?
In our urls and in the text of the buttons we have comma. Its causing an error. Is there a way to change the delimiting character for the menu arguments?
What is the map interface?
How primary key is implemented in Oracle?
What is an abstract method?
Name three component subclasses that support painting?