This document discusses inheritance in Java, a key concept in Object-Oriented Programming that allows one class to inherit features from another. It explains how to use inheritance with the 'extends' keyword, defines important terminologies such as superclass and subclass, and highlights the concept of reusability. Additionally, it introduces different types of inheritance, although details on those types are not provided in the excerpt.
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 ratings0% found this document useful (0 votes)
4 views7 pages
Lecture 3.1
This document discusses inheritance in Java, a key concept in Object-Oriented Programming that allows one class to inherit features from another. It explains how to use inheritance with the 'extends' keyword, defines important terminologies such as superclass and subclass, and highlights the concept of reusability. Additionally, it introduces different types of inheritance, although details on those types are not provided in the excerpt.
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
You are on page 1/ 7
Java Programming
UNIT 3
Mrs. Sneha D. Patil
(Assistant Professor, E&C) INDEX Inheritance How to Use Inheritance in Java? Important Terminologies Used in Java Inheritance Types Of Inheritance Inheritance Java, Inheritance is an important pillar of OOP(Object-Oriented Programming). It is the mechanism in Java by which one class is allowed to inherit the features(fields and methods) of another class. In Java, Inheritance means creating new classes based on existing ones. A class that inherits from another class can reuse the methods and fields of that class. In addition, you can add new fields and methods to your current class as well. How to Use Inheritance in Java?
The extends keyword is used for
inheritance in Java. Using the extends keyword indicates you are derived from an existing class. In other words, “extends” refers to increased functionality. Syntax : class DerivedClass extends BaseClass { //methods and fields } Important Terminologies Used in Java Inheritance
Class: Class is a set of objects which shares common
characteristics/ behavior and common properties/ attributes. Class is not a real-world entity. It is just a template or blueprint or prototype from which objects are created. Super Class/Parent Class: The class whose features are inherited is known as a superclass(or a base class or a parent class). Sub Class/Child Class: The class that inherits the other class is known as a subclass(or a derived class, extended class, or child class). The subclass can add its own fields and methods in addition to the superclass fields and methods. Reusability: Inheritance supports the concept of “reusability”, i.e. when we want to create a new class and there is already a class that includes some of the code that we want, we can derive our new class from the existing class. By doing this, we are reusing the fields and methods of the existing class. TYPES OF INHERITANCE