class A{
m2(){
}
}
class B extends A{
m2(){
}
}
class c extends B{
m2(){
}
}
class my_class extends c{
m2(){
}
pulic static void main(){
...My_class a = new my_class();
super.super.super.m2(); is this is leagal
if not find what is the legal procedure in order to call A's
version of m2();
}
Answer Posted / monika
Above solution looks correct but it is not taking advantage
of inheritance.
I hope following code does the trick.
class A
{
void m2()
{System.out.println("in class A");
}
}
class B extends A
{
void m2()
{ System.out.println("in class B");
}
}
class c extends B
{
void m2()
{
System.out.println("in class c");
}
}
class Check extends c
{
void m2()
{
System.out.println("in check()");
}
public static void main(String[] args)
{
A obj =new Check();
obj.m2();
}
}
Is This Answer Correct ? | 2 Yes | 4 No |
Post New Answer View All Answers
How do you check whether the list is empty or not in java?
What is the file extension for java?
What is difference between variable declaration and definition?
What is the default value of float and double datatype in java?
Can we execute java program without main method?
Is java 11 paid version?
What is the synonym of procedure?
What is vector capacity in java?
What is generic class?
what happens when a thread cannot acquire a lock on an object? : Java thread
What is the output of the below java program?
What is java string pool?
How many types of classes are there in java?
What are keywords give examples?
What is externalizable interface?