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
What is the structure of java?
How do you create a sop?
What is immutable in java?
What is the flag in java?
What is nullpointerexception?
Can I use % with real numbers?
How does the garbage collector works in java?
How will you get the platform dependent values like line separator, path separator, etc., ?
List the interfaces which extends collection interface?
what is daemon thread and which method is used to create the daemon thread? : Java thread
Explain list interface?
What is difference between path and classpath variables?
What is sorting in java?
Can we define private and protected modifiers for the members in interfaces?
What is the inheritance?