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


Please Help Members By Posting Answers For Below Questions

Difference between DurableSubscription and non- DurableSubscription?

1716


What are the sequence of steps to write pub or sub model kind of application?

1895


Define aop(assepct oriented programing)?

644


Java is fully object oriented languages or not?

542


What is the RMI and Socket?

627






Name three subclasses of the component class?

619


What is the diffrence between a local-tx-datasource and a xa-datasource?

582


Which component handles cluster communication in jboss?

628


Brief description about local interfaces?

630


What is scalable, portability in the view of J2EE?

1879


What is the relation between the infobus and rmi?

560


What are transaction attributes?

616


What modifiers may be used with an interface declaration?

561


what is Activation Instantinator?

1917


What are the diff types of exception?

565