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

What is ioc concept?

701


what is Activation Instantinator?

1919


What are the difference between RMI and CORBA?

623


Name three component subclasses that support painting?

624


What are the types of scaling?

565






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 ..

1745


What is a class loader?

595


What is the difference between the session.get() method and the session.load() method?

610


What’s jboss cache in short?

613


Why won’t the jvm terminate when I close all the application windows?

765


Difference between hashmap and hashtable?

616


What is bean? Where can it be used?

585


Why does the option tag render selected=selected instead of just selected?

686


What is chat area? Explain.

567


What is synchronization and why is it important?

557