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
Which containers use a border layout as their default layout?
What is a class loader? What are the different class loaders used by jvm?
Write a program to show synchronization?
What is the difference between the session.get() method and the session.load() method?
Why won’t the jvm terminate when I close all the application windows?
What event results from the clicking of a button?
How messaging services are done, before release of JMS?
Can we sent objects using Sockets?
Why is actionform a base class rather than an interface?
how do you Handle Front End Application data against DB with example?
What is the difference between RMI registry and OS Agent?
Explain what is orm?
What modifiers may be used with an inner class that is a member of an outer class?
What is the purpose of the notify() method?
Define prototype?