Method overloading and method overriding

RomitRajSingh1 177 views 11 slides Jun 29, 2024
Slide 1
Slide 1 of 11
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11

About This Presentation

M


Slide Content

OOP PresentationOOP Presentation
Presented by Romit Raj Singh(ECE/2021/24)
Topic :Topic :
Method Overloading and Method OverridingMethod Overloading and Method Overriding

CONTENTCONTENT
01.
02.
03.
Method Overloading
Differences
Method Overriding

METHOD OVERLOADINGMETHOD OVERLOADING
If a class has multiple methods having same name but different in parameters, it is known as Method
Overloading.If we have to perform only one operation, having same name of the methods increases the
readability of the program.
Method overloading in Java is also known as Compile-time Polymorphism, Static Polymorphism, or Early
binding. In Method overloading compared to the parent argument, the child argument will get the
highest priority.
AdvantagesAdvantages
Method overloading improves the Readability and reusability of the program.
Method overloading reduces the complexity of the program.
Using method overloading, programmers can perform a task efficiently and effectively.
Using method overloading, it is possible to access methods performing related functions with
slightly different arguments and types.
Objects of a class can also be initialized in different ways using the constructors.

CODECODE

OUTPUTOUTPUT

METHOD OVERRIDINGMETHOD OVERRIDING
In Java, Overriding is a feature that allows a subclass or child class to provide a specific
implementation of a method that is already provided by one of its super-classes or parent
classes. When a method in a subclass has the same name, the same parameters or signature, and
the same return type(or sub-type) as a method in its super-class, then the method in the
subclass is said to override the method in the super-class.
AdvantagesAdvantages
Helps in writing generic code based on parent class or interface as object resolution happens
at runtime
1.
Provides multiple implementation of same method and can invoke parent class overridden
method using super keyword
2.
Defines what behavior a class can have and implementation of behavior has been taken care
by class which is going to implement.
3.

CODECODE

OUTPUTOUTPUT

Thank youThank you
very much!very much!
Tags