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 difference between RMI registry and OS Agent?
What are various types of class loaders used by jvm?
we use MainFrame and using os390 for operating system with DB2 data base in IRAN and interest programing with java and use webspere for world wide,please help me where i should start?
Write a singleton program?
Why a component architecture for the java platform?
Why is actionform a base class rather than an interface?
If we opened Windows Internet Explorer 4 times, does it starts 4 processes or 4 threads?
what are getters and setters in Java with examples?
What are the different class loaders used by jvm?
Can I use multiple html form elements with the same name?
Which component handles cluster communication in jboss?
Why doesn’t the focus feature on the tag work in every circumstance?
If I wanted to use a solarisui for just a jtabbedpane, and the metal ui for everything else, how would I do that?
Can I map more than one table in a cmp?
What are local interfaces? Describe.