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 modular application? What does module-relative mean?
difference between ejb,struts,hibernate,spring and jsp
Are we allowed to change the transaction isolation property in middle of a transaction?
what is a portable component?
What is the purpose of the finally clause of a try-catch-finally statement?
What is Remote Server?
How would you detect a keypress in a jcombobox?
What is the form of storage space in java?
When is the best time to validate input?
What modifiers may be used with an inner class that is a member of an outer class?
What is the argument type of a programs main() method?
What is clustering? What are the different algorithms used for clustering?
Is jvm a overhead?
What restrictions are placed on the values of each case of a switch statement?
If I wanted to use a solarisui for just a jtabbedpane, and the metal ui for everything else, how would I do that?