answersLogoWhite

0


Best Answer

In advanced programming languages, the re-usability of a portion of code capable of performing a given function is an unique advantage. The compartmentalization of a code which can be reused later and invoked by the class name is referred as object inheritance. In classical inheritance classes are used while in object inheritance sub classes and super classes are add-on features. It saves lengthy redundant coding by inherting the desired code function and calling it by name .

-JP Morgan

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

Inheritance is the Java object oriented feature wherein functionality in one class is inherited or available for use in another class. It can be compared to parent-child relationships.

1. Single Inheritance

A Scenario where one class is inheriting/extending the behavior of just one super class.

Ex: public class Ferrari extends Car {…}

2. Multilevel Inheritance

A Scenario where one class is inheriting/extending the bahavior of another class which in turn is inheriting behavior from yet another class.

Ex: public class Automobile {…}

Public class Car extends Automobile {…}

Public class Ferrari extends Car {…}

This multilevel inheritance actually has no limitations on the number of levels it can go. So as far as java goes, it is limitless. But for maintenance and ease of use sakes it is better to keep the inheritance levels to a single digit number.

3. Multiple Inheritance

Actually, java does not support multiple inheritance. You can achieve partial multiple inheritance using interfaces but java is not like C or C++ where you can do direct multiple inheritance. However, you can achieve partial multiple inheritance with the help of interfaces.

Ex: public class FerrariF12011 extends Ferrari implements Car, Automobile {…}

And this is under the assumption that Car and Automobile are interfaces.

Here if you see, though you don't inherit concrete code from the Car or the Automobile interface, you do inherit skeleton methods that determine the way your class eventually behaves and hence this can be considered partial Multiple Inheritance.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Types of Inheritance:

1. Single Inheritance

A Scenario where one class is inheriting/extending the behavior of just one super class.

Ex: public class Ferrari extends Car {…}

2. Multilevel Inheritance

A Scenario where one class is inheriting/extending the bahavior of another class which in turn is inheriting behavior from yet another class.

Ex: public class Automobile {…}

Public class Car extends Automobile {…}

Public class Ferrari extends Car {…}

This multilevel inheritance actually has no limitations on the number of levels it can go. So as far as java goes, it is limitless. But for maintenance and ease of use sakes it is better to keep the inheritance levels to a single digit number.

3. Multiple Inheritance

Actually, java does not support multiple inheritance. You can achieve partial multiple inheritance using interfaces but java is not like C or C++ where you can do direct multiple inheritance. However, you can achieve partial multiple inheritance with the help of interfaces.

Ex: public class FerrariF12011 extends Ferrari implements Car, Automobile {…}

And this is under the assumption that Car and Automobile are interfaces.

Here if you see, though you don't inherit concrete code from the Car or the Automobile interface, you do inherit skeleton methods that determine the way your class eventually behaves and hence this can be considered partial Multiple Inheritance.

4. Hybrid Inheritance

This is the scenario wherein your java code exhibits traits of more than one of the inheritance types explained above. Going with the example above again:

Public class FerrariF12011 extends Ferrari implements Car, Automobile {…}

The above is a combination of both single and multiple inheritance.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is meant by inheritance and types of inheritance?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Does hybrid inheritance consist of ANY two types of inheritance?

There are only two types of inheritance to begin with: single inheritance and multiple inheritance. Since they are mutually exclusive there is no such thing as hybrid inheritance.


What is an inheritance Explain different types of inheritance in c?

C is not an object oriented language and therefore has no native support for inheritance.


Can you have inheritance without polymorphism?

Yes. Inheritance and polymorphism are two different things. Inheritance is when the attributes and methods of a class are inherited by a deriving class that creates a more specialized type. Polymorphism is when two methods exist with the same name, differing only in argument types, or in class type. The former type, argument types, is an example of ad-hoc polymorphism that does not even require a class.


Type of inheritance?

There are 2 Types of genetic Inheritance. 1. Polygenic inheritance, also known as quantitative or multi-factorial inheritance refers to inheritance of a phenotypic characteristic (trait) that is attributable to two or more genes and their interaction with the environment. Polygenic traits do not follow patterns of Mendelian inheritance (qualitative traits). Instead, their phenotypes typically vary along a continuous gradient depicted by a bell curve. Eye color and skin color are both polygenetic traits. 2. Monogenic inheritance is controlled by a single gene, as opposed to multigenic.


What is a relationship in following a-polymorphism b-inheritance c-overloading d-none of these options?

Inheritance.

Related questions

Does hybrid inheritance consist of ANY two types of inheritance?

There are only two types of inheritance to begin with: single inheritance and multiple inheritance. Since they are mutually exclusive there is no such thing as hybrid inheritance.


Different types of inheritances?

Single Inheritance Multiple Inheritance Multilevel Inheritance


Types of heredity?

Mendelian inheritance, incomplete dominance, codominance, multiple alleles, polygenic inheritance, and sex-linked inheritance.


What is an inheritance Explain different types of inheritance in c?

C is not an object oriented language and therefore has no native support for inheritance.


What are the different types of inheritence?

there are several type of inheritance are exist like 1. single inheritance 2. double inheritance 3. multiple 4. multilevel 5. heirarchical inheritance


What are the names of some genetic inheritance patterns?

Types of dominance, multiple alleles, sex linked inheritance, polygenic inheritance and maternal inheritance.


What type of inheritance pattern are these rabbits likely displaying?

Types of dominance, multiple alleles, sex linked inheritance, polygenic inheritance and maternal inheritance.


What is meant by the P generation?

The parent individuals from which offspring are derived in studies of inheritance


Is it possible to implement method overriding in each and every type of inheritance?

Yes. Method Overriding is not possible without inheritance and it can be done in all possible types of inheritance.


Explain different types of inheritance of object oriented programming?

== ==


Types of inheritance does the Common Type System support?

asdasd


Blood types A B AB and O are the result of what inheritance?

it depends on what blood type that your parent has