Computer Applications
Explain various types of inheritance.
Encapsulation & Inheritance in Java
2 Likes
Answer
The various types of inheritance are as follows:
- Single Inheritance — When a class is derived from only one base class, it is known as single inheritance.
- Multiple Inheritance — When a sub class is inherited from multiple base classes, it is known as multiple inheritance.
- Hierarchical Inheritance — When many sub classes are inherited from a single base class, it is known as hierarchical inheritance.
- Hybrid Inheritance — When more than one type of inheritance forms are used together, it is known as hybrid inheritance.
- Multilevel Inheritance — When a sub class is inherited from a class that itself is being inherited from another class, it is known as multilevel inheritance.
Answered By
3 Likes
Related Questions
What does the inheritance mechanism allow one class to acquire from another?
How is inheritance transitive? Explain.
Why do you need to use inheritance? Give two reasons.
Declare a public class CoolClass.
- Write the header for a public member method CoolMethodA.
- Write the header for an integer member method CoolMethodB that should be accessible to the classes in the package but not to derived classes.
- Write the header for an integer member method CoolMethodC that should be accessible only to other methods of the class.
- Write the header for a character member method CoolMethodD that should be accessible to the classes in the package and any derived classes.