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

How to implement dphibernate to activate lazy loading in Flex with java ?thanx in advance!

2546


What are JTA/JTS and how they used by client?

1710


Brief description about local interfaces?

616


How would you reatach detached objects to a session when the same object has already been loaded into the session?

671


How are the elements of a borderlayout organized?

589






which type of objects reference will be given to client?

2019


Define aop(assepct oriented programing)?

624


What is JTS?

1857


Explain what is orm?

667


Can we sent objects using Sockets?

637


Why use POJO when I can use hashmap

2041


What is the difference between a menuitem and a checkboxmenuitem?

575


What is difference between object state and behavior?

569


In inglish: How to convert jar to exe files? Em português: Como converter arquivos .jar para .exe?

2147


What are the types of scaling?

545