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
Define aop(assepct oriented programing)?
Define the remote object implementation?
To what value is a variable of the string type automatically initialized?
What is a modular application?
Are there books about seam?
Can you give me a simple example of using the requiredif validator rule?
Java is fully object oriented languages or not?
What do you mean by Socket Programming?
What is in-memory replication?
For which statements does it make sense to use a label?
What is the difference between a menuitem and a checkboxmenuitem?
What is permgen or permanent generation?
What are the benefits of detached objects?
What is the difference between session and entity beans?
What are the call back methods in entity bean?