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 clustering? What are the different algorithms used for clustering?
What is the difference between RMI registry and OS Agent?
Explain how will the struts know which action class to call when you submit a form?
To what value is a variable of the string type automatically initialized?
What is a sessionfactory? Is it a thread-safe object?
Which javutil classes and interfaces support event handling?
What is the purpose of the wait() method?
What’s jboss jbpm?
What is the relationship between an event-listener interface and an event-adapter class?
How will you pass parameters in RMI? Why do you serialize?
If I wanted to use a solarisui for just a jtabbedpane, and the metal ui for everything else, how would I do that?
Explain about RMI Architecture?
How are the elements of a cardlayout organized?
Can I use javascript to submit a form?
What are the different methods of identifying an object?