can a static method be overridden

Answer Posted / nisha

/* 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

dostuff();
Animal a=new Dog();
a.doStuff();
}
}

Is This Answer Correct ?    2 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can I use multiple html form elements with the same name?

576


What is the purpose of the finally clause of a try-catch-finally statement?

551


Where can I ask questions and make suggestions about seam?

584


Explain what is synchronization?

566


How to pass parameters in RMI?

1684






Which containers use a border layout as their default layout?

604


What’s jboss cache in short?

586


int x=5,i=1,y=0; while(i<=5) { y=x++ + ++x; i=i+2; } System.out.println(x); System.out.println(y); System.out.println(i); How to solve this? Please explain!

1358


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

2551


How many times may an objects finalize() method be invoked by the garbage collector?

668


How to determine SGA site?

1902


Explain the advantages and disadvantages of detached objects.

568


What is the difference between ear, jar and war file?

564


Can I map more than one table in a cmp?

590


What are the pros and cons of detached objects?

541