can a static method be overridden
Answer Posted / nisha
/* 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
dostuff();
Animal a=new Dog();
a.doStuff();
}
}
| Is This Answer Correct ? | 2 Yes | 4 No |
Post New Answer View All Answers
How would you detect a keypress in a jcombobox?
Why are my checkboxes not being set from on to off?
How can I scroll through list of pages like the search results in google?
Do we need to override service() method
Explain how will the struts know which action class to call when you submit a form?
Explain what is synchronization?
Are enterprise beans allowed to use thread.sleep()?
What are the types of scaling?
What is the purpose of the notifyall() method?
Whats new with the stop(), suspend() and resume() methods in jdk 1.2?
what is an isolation level?
Is the session factory thread safe?
How a component can be placed on Windows?
What if the static modifier is removed from the signature of the main method?
What does module-relative mean?