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
Difference between DurableSubscription and non- DurableSubscription?
What are the sequence of steps to write pub or sub model kind of application?
Define aop(assepct oriented programing)?
Java is fully object oriented languages or not?
What is the RMI and Socket?
Name three subclasses of the component class?
What is the diffrence between a local-tx-datasource and a xa-datasource?
Which component handles cluster communication in jboss?
Brief description about local interfaces?
What is scalable, portability in the view of J2EE?
What is the relation between the infobus and rmi?
What are transaction attributes?
What modifiers may be used with an interface declaration?
what is Activation Instantinator?
What are the diff types of exception?