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
What is Stream Tokenizer?
wahts is mean by dynavalidatorform in struts/
Define the remote object implementation?
What class is used to create Server side object ?
Describe, in general, how java's garbage collector works?
Why does the tag url-encode javascript and mailto links?
What is the difference between long.class and long.type?
Is infobus easy to use?
What is ripple effect?
Which container method is used to cause a container to be laid out and redisplayed?
why static class in java
Can I run seam outside of jboss as?
What is the difference between RMI registry and OS Agent?
Describe responsibilities of Activator?
How to pass parameters in RMI?