Can static methods be overridden?

Answer Posted / sumit pal singh

static class Class1 {
    public static int Method1(){
          return 0;
    }
}
static class Class2 extends Class1 {
    public static int Method1(){
          return 1;
    }




}
public static class Main {
    public static void main(String[] args){
            
          Class1.Method1();
          Class2.Method1();
    }
}

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How is hashset defined in java?

519


Why do we create public static method in java?

582


What is wrapper class example?

539


How are this() and super() used with constructors in java programming?

573


Is it possible to specify multiple jndi names when deploying an ejb?

560






What are the wrapped, classes?

601


What are some examples of variable costs?

495


What will happen if there is a default method conflict as mentioned above and we have specified the same signature method in the base class instead of overriding in the existing class ?

521


Which programming language is most secure?

534


Is java developer a good career?

556


Can vector have duplicates in java?

509


Considering notepad/ie or any other thing as process, what will happen if you start notepad or ie 3 times? Where 3 processes are started or 3 threads are started?

656


What is a class reference?

555


Why stringbuilder is not thread safe in java?

574


What is break and continue statement?

616