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

How does class forname work in java?

747


How many types of string data types are there?

779


What is the difference between class & structure?

818


What is the final access modifier in java?

839


What is the purpose of the file class in java programming?

769


What is a nested structure?

756


what is function overloading in java?

982


What is the difference between a checked and an unchecked exception?

777


What is a key in java?

758


Can we execute java program without main method?

755


What is the difference between the size and capacity of a vector?

806


What is a boolean field?

750


What does it mean that a class or member is final?

768


What is a singleton in genetics?

828


What is "this" keyword in java? Explain

892