Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is the structure of java?

1034


How do you create a sop?

1011


What is immutable in java?

1071


What is the flag in java?

1067


What is nullpointerexception?

1076


Can I use % with real numbers?

1024


How does the garbage collector works in java?

1094


How will you get the platform dependent values like line separator, path separator, etc., ?

1028


List the interfaces which extends collection interface?

958


what is daemon thread and which method is used to create the daemon thread? : Java thread

977


Explain list interface?

967


What is difference between path and classpath variables?

1097


What is sorting in java?

992


Can we define private and protected modifiers for the members in interfaces?

1106


What is the inheritance?

975