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
How to implement dphibernate to activate lazy loading in Flex with java ?thanx in advance!
What are JTA/JTS and how they used by client?
Brief description about local interfaces?
How would you reatach detached objects to a session when the same object has already been loaded into the session?
How are the elements of a borderlayout organized?
which type of objects reference will be given to client?
Define aop(assepct oriented programing)?
What is JTS?
Explain what is orm?
Can we sent objects using Sockets?
Why use POJO when I can use hashmap
What is the difference between a menuitem and a checkboxmenuitem?
What is difference between object state and behavior?
In inglish: How to convert jar to exe files? Em português: Como converter arquivos .jar para .exe?
What are the types of scaling?