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
Explain the difference between serializable and externalizable in java?
What data type is true or false?
Explain JMS in detail.
Can we override data members in java?
How do you use substring in java?
What is the disadvantage of synchronization?
What is a constructor, constructor overloading in java?
Give few examples of final classes defined in Java API?
Give example to differentiate between call by value and call by reference.
What is threaded programming and when is it used? : Java thread
What is static in java?
What is variable in java?
What are actual parameters?
What are the different ways of creating thread?
Why is java called java?