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 message driven beam?
What do you know about seam?
Define the remote object implementation?
What class is used to create Server side object ?
wahts is mean by dynavalidatorform in struts/
what is an isolation level?
What are the different types of exception?
What is threadfactory?
How substring() method of string class create memory leaks?
how do you Handle Front End Application data against DB with example?
Can I use multiple html form elements with the same name?
If your ui seems to freeze periodically, what might be a likely reason?
What is the RMI and Socket?
What is the difference between static and non-static with examples?
What are the difference between RMI and CORBA?