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
Is main an identifier?
What is loop in java?
Why do we need singleton class?
What is string in java with example?
What is empty list in java?
What is array list in java?
What is a file pointer?
Explain enumeration in java?
What is the method in java?
What is the purpose of using javap?
What is null in java?
What is main function purpose?
What is super constructor?
What is try-with-resources in java?
Define array. Tell me about 2-D array.