can a static method be overridden

Answer Posted / ravi ranjan

Yes a static method can be overridden
see following two classes

public class Test extends Test2{

public static void main(String args[]){
String str="";
int b=Test.cal(4);
System.out.println(b);
Test t =new Test();
t.displayX();
}
public static int cal(int a){
int c=a*a;
System.out.println("Hi I am Child" );
return c;
}
}

class Test2 {
public static void main(String args[]){

}

public static int cal(int a){
int c=a*a;
System.out.println(c);
return c;
}

public void displayX(){
System.out.println("HI i am in Super");
}

}

Compile this code there is no compile or run time error

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is abstract schema?

546


whats is mean by connectionpooling

1557


what is a portable component?

1456


What event results from the clicking of a button?

688


how i secure my site with the https protocol.what are the steps?

1727






What is a policy?

1760


Can I run seam outside of jboss as?

629


What is a class loader? What are the different class loaders used by jvm?

575


What is the difference between the font and fontmetrics classes?

552


What method is invoked to cause an object to begin executing as a separate thread?

563


What class is used to create Server side object ?

1658


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

2147


What modifiers may be used with an inner class that is a member of an outer class?

566


What you mean by COM and DCOM?

605


What are transaction attributes?

607