KEMBAR78
Unit 09 Inheritance | PDF | Inheritance (Object Oriented Programming) | Method (Computer Programming)
0% found this document useful (0 votes)
5 views3 pages

Unit 09 Inheritance

The document discusses key Object-Oriented Programming concepts in Java, focusing on inheritance and polymorphism. Inheritance allows one class to inherit features from another, promoting reusability, while polymorphism enables a single action to be performed in multiple ways through method overloading and overriding. Additionally, the final keyword is explained as a restriction mechanism that can be applied to variables, methods, and classes.

Uploaded by

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

Unit 09 Inheritance

The document discusses key Object-Oriented Programming concepts in Java, focusing on inheritance and polymorphism. Inheritance allows one class to inherit features from another, promoting reusability, while polymorphism enables a single action to be performed in multiple ways through method overloading and overriding. Additionally, the final keyword is explained as a restriction mechanism that can be applied to variables, methods, and classes.

Uploaded by

rinkubaria465
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

OBJECT ORIENTED CONCEPTS & PROGRAMMING–1 (CORE JAVA)

UNIT 09: INHERITANCE


❖ Inheritance in 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.
• Important terminology:
o Super Class: The class whose features are inherited is known as
superclass(or a base class or a parent class).
o Sub Class: The class that inherits the other class is known as a
subclass(or a derived class, extended class, or child class).
o The subclass can add its own fields and methods in addition to the
superclass fields and methods.
o Reusability: Inheritance supports the concept of “reusability”.
• The keyword used for inheritance is extends.
• Syntax :
class derived-class extends base-class
{
//methods and fields
}
❖ Polymorphism :
• Polymorphism in Java is a concept by which we can perform a single
action in different ways.
• Polymorphism is derived from 2 Greek words: poly and morphs. The
word "poly" means many and "morphs" means forms. So polymorphism
means many forms.
• There are two types of polymorphism in Java: compile-time
polymorphism and runtime polymorphism.
• We can perform polymorphism in java by method overloading and
method overriding.
1. Compile-time Polymorphism:
• Compile-time polymorphism is also known as static polymorphism or
early binding.
• Compile-time polymorphism is a polymorphism that is resolved during
the compilation process.
• Overloading of methods is called through the reference variable of a
class. Compile-time polymorphism is achieved by method
overloading and operator overloading.
• Method overloading :
• We can have one or more methods with the same name that are
solely distinguishable by argument numbers, type, or order.
• Method Overloading occurs when a class has many methods with the
same name but different parameters.
• Two or more methods may have the same name if they have other
numbers of parameters, different data types, or different numbers of
parameters and different data types.
2. Runtime Polymorphism:
• It is also known as Dynamic Method Dispatch. Dynamic polymorphism is
a process in which a call to an overridden method is resolved at runtime,
thats it is called runtime polymorphism.
• Method overriding :
• Declaring a method in sub class which is already present in parent
class is known as method overriding.
• Overriding is done so that a child class can give its own
implementation to a method which is already provided by the parent
class.
• In this case the method in parent class is called overridden method
and the method in child class is called overriding method.
❖ Final Keyword :
• The final keyword in java is used to restrict the user. The java final
keyword can be used in many context. Final can be:
1. variable
2. method
3. class
• The final keyword can be applied with the variables, a final variable that
have no value it is called blank final variable or uninitialized final
variable.
• It can be initialized in the constructor only.

2
• The blank final variable can be static also which will be initialized in the
static block only.

You might also like