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
If we opened Windows Internet Explorer 4 times, does it starts 4 processes or 4 threads?
Whats new with the stop(), suspend() and resume() methods in jdk 1.2?
What is a class loader? What are the different class loaders used by jvm?
which type of objects reference will be given to client?
whats is mean by connectionpooling
Which javutil classes and interfaces support event handling?
Explain about local interfaces.
What is bean? Where can it be used?
How substring() method of string class create memory leaks?
What are the difference between RMI and CORBA?
How many times may an objects finalize() method be invoked by the garbage collector?
What is a tasks priority and how is it used in scheduling?
Difference between hashmap and hashtable?
To what value is a variable of the string type automatically initialized?
What is the form of storage space in java?