Can we override static methods?

Answer Posted / amitasite

you cannot override static method from super class.

e.g.,

class SuperType{
public static void method(){
System.out.println("Super Static");
}
}

class SubType extends SuperType{
public void method(){
System.out.println("Super Static");
}
}

It will give compilation error : Instance method cannot
override static method from SuperType

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When throws keyword is used?

566


define polymorphism in java

611


Can we have a method name same as class name in java?

561


Discuss 2D arrays.

576


Why is serialization required?

515






Can we rethrow the same exception from catch handler?

539


What is data structure in java?

510


What is the difference between jfc & wfc?

570


What is a null point?

531


What is a byte string?

594


Detail discussions on JVM, memory management and garbage collector.

528


Can a final variable be null?

524


Can we instantiate interface in java?

651


Why spring singleton is not thread safe?

543


What does business logic mean?

474