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
What is the difference between a break statement and a continue statement?
Can inner class be public in java?
What is meant by data hiding/encapsulation?
When the constructor of a class is invoked?
What is the byte range?
Which is faster call by value or call by reference?
When can an object reference be cast to an interface reference in java programming?
What is instance example?
What are the practical benefits, if any, of importing a specific class rather than an entire package (e.g. Import java.net.* Versus import java.net.socket)?
Is java 9 released?
What is object-oriented programming?
How do I know if java is installed?
Is arraylist ordered?
What is difference between printf and scanf?
Can memory leak in java?