In Inheritence concept, i have a static method in super
class and i am inheriting that class to one sub class.in
that case the static method is inherited to sub class or
not????

Answer Posted / dhanunjaya

see below example it is possible to inherite the static methods from the parent class

class Test{

void m1(){

System.out.println("test instance method");
}

static void m2(){

System.out.println("test static method");
}

}

class Demo extends Test{


void m3(){

System.out.println("demo instance method");
}


public static void main(String ar[]){
System.out.println("main method");
Demo d=new Demo();

d.m3();
d.m2();
}
}
o/p:main method
demo instance method
test static method

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is meant by anonymous class?

583


What is the r character?

580


What is a super method?

525


Can one thread block the other thread?

597


Can we define static methods inside interface?

513






What is javac in java?

552


What is the difference between a constructor and a method?

560


How many threads does a core java have?

503


What are java packages? What is the significance of packages?

559


Explain when noclassdeffounderror will be raised ?

609


What is the epoch date?

562


What is singleton class and how can we make a class singleton?

655


How do you remove duplicates in java?

514


What is the difference between actual and formal parameters?

503


does java support pointers?

556