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 difference between equal and == in java?
State differences between C and Java?
What does flagged out mean?
What is the difference between numeric and integer?
What kind of variables can a class consist?
can I implement my own start() method? : Java thread
How many static init can you have?
what is thread? What are the high-level thread states? : Java thread
Compare overloading and overriding?
Explain hashset and its features?
Can we have multiple classes in single file ?
What is the byte range?
How do you invoke a method?
Are constructors methods?
What are unchecked exceptions in java?