answersLogoWhite

0

What is inheritance and discus type of inheritance?

Updated: 8/19/2019
User Avatar

Wiki User

12y ago

Best Answer

Inheritance is the feature in Java where you use the features/code available in one class in another

Types:

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.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is inheritance and discus type of inheritance?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What type of inheritance is eye color?

polygenic inheritance


What type of inheritance is supported by php?

PHP Supports Multi Level Inheritance


What type inheritance is blood type?

multiple allels


Must a discus leave the hand from the front or back?

Type your answer here... front


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 type of inheritance pattern are these rabbits likely displaying?

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


What is the type of inheritance that would suggest the concept of blending?

Blending inheritance is inheritance in which contrasting parental characters appear as a blend in the offspring.


What has the author Bernd Degen written?

Bernd Degen has written: 'Pr\\' 'Discus in the Community Tank' 'Degen discus book' -- subject(s): Discus (Fish) 'Wild-Caught Discus' 'The Proper Care of Discus' 'The Discus--\\' -- subject(s): Discus (Fish), Pictorial works


What is the name of a sport where athletes throw a flat circle?

discus throw


What type of inheritance is blood typing?

multiple allels


What type of inheritance is Roan in cows and bulls?

Codominance.


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.