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 / priynajan

No it is not leagal the correct procedure is:
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 A();
obj.m2();
}
}
..
Works correctly :-)

Is This Answer Correct ?    1 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between null and void?

537


What is the size of arraylist in java?

610


What is jvm? Why is java called the platform independent programming language?

551


What do you mean by checked exceptions?

542


What is the difference between a local variable and an instance variable?

554






What is the use of singleton class?

527


What is ternary operator in java?

599


What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?

636


What is the new line character?

562


What do you mean by mnemonics?

537


How do you achieve singleton?

537


What is navigable map in java?

527


What is numeric data type?

535


Can we override data members in java?

632


How can we pass argument to a function by reference instead of pass by value?

588