Java Inheritance
Java Inheritance
Inheritance
Inheritance
• Same inheritance concept of C++ in Java with some
modifications
– One class inherits the other using extends keyword
– The classes involved in inheritance are known as
superclass and subclass
– Multilevel inheritance but no multiple inheritance
– There is a special way to call the superclass’s constructor
– There is automatic dynamic method dispatch
• Inheritance provides code reusability (code of any
class can be used by extending that class)
Prepared By - Rifat Shahriyar 2
Simple Inheritance
To prevent overriding
To prevent inheritance