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
How many bits is a double?
What is boolean strategy?
What is the difference between a break statement and a continue statement?
Is java a utf 8 string?
What is the differences between heap and stack memory in java? Explain
what type of questions asked for barclays technologies pune please send urgent
Can set contain duplicates?
What is Garbage Collection in Java
What is a arraylist in java?
Can inner class extend any class?
Difference between default and protected access specifiers?
What are the new features in java 8? Explain
How will you calculate the depth of a binary tree if the tree contains 15 nodes?
What is compareto?
How static variable work in java?