Java langauge supports single& multiple inheritance,but it doesn't support multilevel inheritance.
It allows you to extend a class (called the base
class or superclass) with another class (called the derived class or subclass).
in java ,'extends' keyword is used to achieve inheritance,for example:
public class A{
}
public class M extends Al{
}
public class R extends A{
}
public class D extends M{
}
Now based on the above example,we get:
A is the superclass of M class.
A is the superclass of R class.
M and Reptile are sub classes of A class.
D is the subclass of both M and A classes.
Note: With use of the extends keyword the subclasses will be able to inherit all the properties of the superclass except for the private properties of the superclass.
The following kinds of inheritance are there in java:
Simple Inheritance
Multilevel Inheritance
Pictorial Representation of Simple and Multilevel Inheritance
Single Inheritance Multiple Inheritance



No comments:
Post a Comment