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


Please Help Members By Posting Answers For Below Questions

How do you check whether the list is empty or not in java?

516


What is the file extension for java?

614


What is difference between variable declaration and definition?

515


What is the default value of float and double datatype in java?

537


Can we execute java program without main method?

524






Is java 11 paid version?

514


What is the synonym of procedure?

533


What is vector capacity in java?

605


What is generic class?

651


what happens when a thread cannot acquire a lock on an object? : Java thread

544


What is the output of the below java program?

596


What is java string pool?

546


How many types of classes are there in java?

523


What are keywords give examples?

583


What is externalizable interface?

584