0% found this document useful (0 votes)
4 views6 pages

Java Inheritance: Subclass and Superclass

The document discusses Java inheritance, explaining the concepts of subclass (child) and superclass (parent) and how to use the 'extends' keyword for inheritance. It emphasizes the benefits of code reusability when creating new classes based on existing ones. Additionally, it mentions the 'final' keyword to prevent other classes from inheriting from a specific class.

Uploaded by

r11dchaser
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views6 pages

Java Inheritance: Subclass and Superclass

The document discusses Java inheritance, explaining the concepts of subclass (child) and superclass (parent) and how to use the 'extends' keyword for inheritance. It emphasizes the benefits of code reusability when creating new classes based on existing ones. Additionally, it mentions the 'final' keyword to prevent other classes from inheriting from a specific class.

Uploaded by

r11dchaser
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

HMANI 201:

OBJECT ORIENTED PROGRAMMING I –


INTRO TO JAVA

L9 – JAVA INHERITANCE

MS CHIMHENO
rebeccachimheno@[Link]
JAVA INHERITANCE (SUBCLASS AND SUPERCLASS)

In Java, it is possible to inherit attributes and methods


from one class to another.
We group the "inheritance concept" into two categories:
o subclass (child) - the class that inherits from another class
o superclass (parent) - the class being inherited from
To inherit from a class, use the extends keyword.
WHY AND WHEN TO USE "INHERITANCE"?

It is useful for code reusability: reuse attributes and


methods of an existing class when you create a new
class.
JAVA INHERITANCE (SUBCLASS AND SUPERCLASS)
JAVA INHERITANCE (SUBCLASS AND SUPERCLASS)
THE FINAL KEYWORD
 If you don't want other classes to inherit from a class, use the
final keyword:
 If you try to access a final class, Java will generate an error

You might also like