can a static method be overridden

Answer Posted / dheerendra

static method can be overriden the case is that in in
subclass that method should also be static.

class A {
static void something () { System.out.println("static method
in A");}
}

class B extends A {
static void something () {System.out.println("static method
in B");}
}

class TestClass{

public static void main(String args[]){

A a = new A();
B b = new B();
A.something();
B.something();

A t = new B();
t.something();
}
}

the output is
static method in A
static method in B
static method in A

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the argument type of a programs main() method?

571


What is RMI and what are the services in RMI?

617


How would you create a button with rounded edges?

566


Are there books about seam?

644


Is the infobus client side only?

623






Explain ioc concept?

633


Which javutil classes and interfaces support event handling?

594


Do I have to use jsps with my application?

591


What is Remote Server?

1692


Should synchronization primitives be used on bean methods?

560


which book is better for jdbc ,servlets and jsp

1652


What are the steps to write p-to-p model application?

1970


What are callback interfaces?

597


What are the design considerations while making a choice between using interface and abstract class?

553


Which containers use a border layout as their default layout?

618