can a static method be overridden
Answer Posted / mayank
only static method in a subclass can over ride the static
method in the parent class.
for example
public class A {
public static int display(){
System.out.println("i an in A");
return 1;
}
}
public class B extends A{
public static int display(){
System.out.println("i an in B");
return 1;
}
/*public int display(){
}*/
}
will work fine. but if the subclass tries to override parent
class static method with a non static method it generates
compilation error.
for eg
public class B extends A{
/* public static int display(){
System.out.println("i an in B");
return 1;
}*/
public int display(){
}
}
the above code will result in compilation error.
| Is This Answer Correct ? | 5 Yes | 5 No |
Post New Answer View All Answers
Can you give me a simple example of using the requiredif validator rule?
What are the oops concept?
What you mean by COM and DCOM?
How would you detect a keypress in a jcombobox?
Can I have an action without a form?
What is the diffrence between a local-tx-datasource and a xa-datasource?
whats is statement and procedure
Describe, in general, how java's garbage collector works?
what is meant by JRMP?
What happens when a thread cannot acquire a lock on an object?
Where can I find seam examples and documentation?
Why do I get a duplicate name error when loading a jar file?
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?
Why is actionform a base class rather than an interface?
Why a component architecture for the java platform?