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
Can I use multiple html form elements with the same name?
What is the purpose of the finally clause of a try-catch-finally statement?
Where can I ask questions and make suggestions about seam?
Explain what is synchronization?
How to pass parameters in RMI?
Which containers use a border layout as their default layout?
What’s jboss cache in short?
int x=5,i=1,y=0; while(i<=5) { y=x++ + ++x; i=i+2; } System.out.println(x); System.out.println(y); System.out.println(i); How to solve this? Please explain!
How to implement dphibernate to activate lazy loading in Flex with java ?thanx in advance!
How many times may an objects finalize() method be invoked by the garbage collector?
How to determine SGA site?
Explain the advantages and disadvantages of detached objects.
What is the difference between ear, jar and war file?
Can I map more than one table in a cmp?
What are the pros and cons of detached objects?