can a static method be overridden
Answer Posted / let the code speaks....
* 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
}
}
Running this code produces the output:
a a a
Is This Answer Correct ? | 9 Yes | 6 No |
Post New Answer View All Answers
What is ioc concept?
what is Activation Instantinator?
What are the difference between RMI and CORBA?
Name three component subclasses that support painting?
What are the types of scaling?
cud u help me ... i am struggling with this question... to find all the subsets of a given set for ex.... a,,b,c shud give all the subsets.... i gt the program in c bt nt able to get it in java..... help needed ..
What is a class loader?
What is the difference between the session.get() method and the session.load() method?
What’s jboss cache in short?
Why won’t the jvm terminate when I close all the application windows?
Difference between hashmap and hashtable?
What is bean? Where can it be used?
Why does the option tag render selected=selected instead of just selected?
What is chat area? Explain.
What is synchronization and why is it important?