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
Define the remote object implementation?
What is ripple effect?
Explain the difference between object state and behavior?
which book is better for jdbc ,servlets and jsp
Explain about thread synchronization inside a monitor?
If I wanted to use a solarisui for just a jtabbedpane, and the metal ui for everything else, how would I do that?
What is permgen or permanent generation?
Java is fully object oriented languages or not?
Do I have to use jsps with my application?
What is a session? Can you share a session object between different theads?
Name three subclasses of the component class?
Explain the different types of memory used by jvm?
Do we need to override service() method
What is the diffrence between a local-tx-datasource and a xa-datasource? Can you use transactions in both?
What is a class loader?