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 array dynamic in java?
How to use string tokenizer class.
Is empty .java file name a valid source file name?
Is void a keyword in java?
What is called module?
What is core java called?
What is singletonlist in java?
How are observer and observable used in java programming?
Where can i get Latest SUN Certification Dumps and what are the Sun Certification Codes that are available, Im new to JAVA, so please gimme info as i need to write J2EE - Core Java Certification
Can we have a method name same as class name in java?
Can we execute a program without main?
Write a program in java to create a doubly linked list containing n nodes.
What is the use of singleton?
Why Java is not pure Object Oriented language?
Why does java have different data types for integers and floating-point values?