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
What is the difference between the ‘font’ and ‘fontmetrics’ class?
In RMI, inorder to sent the stub reference to the client, is we have to load the server object first into the memory or can we directly sent reference to the client?
Is the session factory thread safe?
What is the difference between a static and a non-static inner class?
what is meant by JRMP?
Can constructors be synchronized in java?
What is the difference between java class and bean?
Name the class that is used to bind the server object with RMI Registry?
how to use debug in my elipse to solve problems that exist in my project
Is there a guarantee of uniqueness for entity beans?
What is the diffrence between a local-tx-datasource and a xa-datasource? Can you use transactions in both?
What is a clone?
What are the types of scaling?
How are the elements of a borderlayout organized?
What is RMI and what are the services in RMI?