Various forms of inheritance in java
Hi friends,
I am doing the java programming course. I am totally confused regarding various forms of inheritance in java.I have read lots of books, but still confused.
I have trouble in understanding various inheritance of java.It is very difficult to find out the difference among them.
Please help me to understand the various forms of inheritance...
Re: Various forms of inheritance in java
As per my java knowledge, Java supports only three forms of inheritance as below:
1. single level inheritance :
In this type of inheritance "class B extends Class A"
2. Multilevel inheritance:
In this type of inheritance "class C extends class B and class B extends class A"
3. multiple inheritance:
In this type of inheritance "Class C inherits features of Class A as well as features of Class B".
Re: Various forms of inheritance in java
There are only two forms of inheritance in the Java programming language.
i). The standard inheritance form is by extension; a class declares that it extends features of the another class, OR an interface which extends another interface. In this case, the child class or child interface inherits all the features of its parent.
ii). The another form of inheritance is where classes declare that they implement an interface. When a class implements an interface, it can inherits any fields from the base as final constants, but it must provide its own implementation for the interface methods.
Re: Various forms of inheritance in java
Java supports only two type of inheritance i.e Single level and multilevel inheritance. Java doesn't supports Multiple inheritance.
The reasons for exclusion of multiple inheritance from the Java mostly originated from the object oriented, simple and familiar goal. As a simple language, creators of java wanted a language in which most developers could grasp without any extensive training. According to designers' opinion, multiple inheritance can causes more problems as well as confusion than it solves. So they cut multiple inheritance concept from the java language