can a static method be overridden
Answer Posted / let the code speaks....
* STATIC METHODS CANT BE OVERRRIDDEN....*
class Animal {
static void doStuff() {
System.out.print("a ");
}
}
class Dog extends Animal {
static void dostuff() { // it's a redefinition,
// not an override
System.out.print("d ");
}
public static void main(String [] args) {
Animal [] a = {new Animal(), new Dog(), new Animal()};
for(int x = 0; x < a.length; x++)
a[x].doStuff(); // invoke the static method
}
}
Running this code produces the output:
a a a
| Is This Answer Correct ? | 9 Yes | 6 No |
Post New Answer View All Answers
what is a portable component?
What is the map interface?
What does module-relative mean?
Name three component subclasses that support painting?
wahts is mean by dynavalidatorform in struts/
what are getters and setters in Java with examples?
what are the advantages of JTA over JTS?
What is the argument type of a programs main() method?
What is local interface. How values will be passed?
what is an isolation level?
Describe responsibilities of Activator?
what are the activation groupworks?
What is the relation between the infobus and rmi?
If I wanted to use a solarisui for just a jtabbedpane, and the metal ui for everything else, how would I do that?
What is the difference between system.out ,system.err and system.in?