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 gc()?
Is array synchronized in java?
What is a variable in java?
Which graphs are functions?
How we can declare a static variable?
What is the advantage of preparedstatement over statement?
describe synchronization in respect to multithreading? : Java thread
How java enabled high performance?
How do you calculate square roots?
What is formatted output?
what are three ways in which a thread can enter the waiting state? Or what are different ways in which a thread can enter the waiting state? : Java thread
What is a newline character in java?
How can you make a class serializable in java?
Does anyone still use java?
What is the difference between the file and randomaccessfile classes?