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
Why string is not thread safe?
Explain about member inner classes?
What is the super void?
Can string be considered as a keyword?
What do you mean by constructor?
What is the difference between interface & abstract class?
How do you declare an array in java?
What is the collections api?
Is it possible for a yielded thread to get chance for its execution again?
How do you include a string in java?
If a class is declared without any access modifiers, where can the class be accessed?
what is thread? What are the high-level thread states? Or what are the states associated in the thread? : Java thread
Define nashorn in java8.
What are the drawbacks of singleton class?
What are the advantages of assembly language?