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...

What is the multilevel inheritance. and also give the Example
of it ?

Answer Posted / fatima deshmukh

Multilevel inheritance is a java feature where the
properties of a class are inherited by a class which extends
one class and which extend its features...

Example:

public class A {
public String getName(){
return "Fatima";
}
}

public class B extends A {
public int getAge() {
return 25;
}
}

public class C extends B {
public String getAddress(){
return "Panvel,Navi Mumbai India";
}
}

public class D extends C {
public void print {
System.out.println(getName());
System.out.println(getAge());
System.out.println(getAddress());
}
}

This method would print the following in the console:
Fatima
25
Panvel, Navi Mumbai, India

Here in class D you are calling methods that are available
inside classes A, B & C. Though D extends only class C, it
would in turn inherit the properties of the classes extended
by C and its parents.

This is multi level inheritance.

Is This Answer Correct ?    14 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What happens if I remove static from main method?

972


How will you serialize a singleton class without violating singleton pattern?

1902


How can we make string upper case or lower case?

1028


What is the definition of tree ?

967


Which package has light weight components in java programming?

1078


How can you share data between two thread in Java?

900


Explain the term virtual machine?

986


How many types of literals are there in JAVA?

994


What is a class instance variable?

1062


How can we find the sum of two linked lists using stack in java?

1051


Can you write a java class that could be used both as an applet as well as an application?

910


Explain a situation where finally block will not be executed?

974


What is the disadvantage of synchronization?

969


Is java a digit method?

949


What is thread safe java?

870