Page Stats
Visitor: 223
Java Inheritance
Inheritance allows sub classes to inherit all the variables and methods of their parent classes.
Types of inheritance:
- Single Inheritance
- Multi-level Inheritance
- Hierarchical Inheritance
- Multiple Inheritance
Public | Protected | Friendly | Private Protected | Private | |
---|---|---|---|---|---|
Same class | Yes | Yes | Yes | Yes | Yes |
Sub class in same package | Yes | Yes | Yes | Yes | No |
Other classes in same package | Yes | Yes | Yes | No | No |
Sub class in other package | Yes | Yes | No | Yes | No |
Non-sub class in other package | Yes | No | No | No | No |