|Types of Inheritance in Java|
There are several different types of inheritance in java. You can use any one of these to create a class. Each type has some advantages and disadvantages. The more classes you have, the simpler they are going to be to create. The following examples show how you can use each type. This will make your code cleaner and more efficient. Inheritance can also be used in combination with polymorphism. The following example shows how you can combine the two.
Single inheritance is the simplest type of inheritance in java. It basically refers to extending a subclass from a single superclass. For example, if you have a class called Apartment_Building, you can extend the Residential_Lot class to access its fields. For example, you could reuse the sizeInSqFt field in Apartment_Building. This kind of inheritance is also called an "IS-A" relationship.
84 months ago