can a static method be overridden
Answer Posted / vivek
If a subclass defines a static method with the same signature as a static method in the superclass, the method in the subclass hides the one in the superclass. The distinction between hiding and overriding has important implications.
public class Animal
{
public static void hide()
{
System.out.format("The hide method in Animal.");
}
public void override()
{
System.out.format("The override method in Animal.");
}
}
public class Cat extends Animal
{
public static void hide()
{
System.out.format("The hide method in Cat.");
}
public void override()
{
System.out.format("The override method in Cat.");
}
}
But still I am not convinced with the exact difference in between hiding and overriding a method...???
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is the immediate superclass of the applet class?
What is the argument type of a programs main() method?
Is jvm a overhead?
How messaging services are done, before release of JMS?
Why a component architecture for the java platform?
Can I map more than one table in a cmp?
What is the difference between the string and stringbuffer classes?
What is the difference between a menuitem and a checkboxmenuitem?
What is the difference between long.class and long.type?
What are the services in RMI ?
What classes of exceptions may be caught by a catch clause?
What are callback interfaces?
How to deploy Jar, War files in J2EE?
What do you mean by Socket Programming?
How are the elements of a borderlayout organized?