0% found this document useful (0 votes)
29 views

Unit-I Chapter in Book - 7 Overloading: - K. Indhu

This document discusses method overloading in Java. It defines method overloading as having two or more methods with the same name but different signatures (parameter types, numbers, or order) in the same class. The document provides an example of overloading the print() method based on different parameter types. It also discusses automatic conversions in overloading, polymorphism, overloading constructors, passing objects as parameters, and copying objects using constructors or the clone() method. The goals are to understand method overloading, polymorphism, and related concepts.

Uploaded by

Ghuru
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)
29 views

Unit-I Chapter in Book - 7 Overloading: - K. Indhu

This document discusses method overloading in Java. It defines method overloading as having two or more methods with the same name but different signatures (parameter types, numbers, or order) in the same class. The document provides an example of overloading the print() method based on different parameter types. It also discusses automatic conversions in overloading, polymorphism, overloading constructors, passing objects as parameters, and copying objects using constructors or the clone() method. The goals are to understand method overloading, polymorphism, and related concepts.

Uploaded by

Ghuru
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
You are on page 1/ 17

UNIT- I

CHAPTER IN BOOK- 7
OVERLOADING
-K. Indhu

SYLLABUS COVERED HERE


Overloading

K. INDHU

GOALS
1. Overloading Methods
2. Method Overloading- Definition &
Example
3. Automatic Conversions in Overloading
4. Polymorphism
5. Overloading Constructors
6. Passing Object as Parameter
7. Copying One Object into another

K. INDHU

I.

OVERLOADING METHODS

In Java, it is possible to have TWO METHODS


WITH SAME NAME INSIDE SAME CLASS,
provided->
The Signature of the methods (with same
name in same class) that is,
(1) Parameter Nos. of the Methods,
(3) Parameter Data Type of the Methods,
(4) Order of Parameter of the Methods,
SHOULD BE DIFFERENT.

II. POINT TO BE NOTED:->


. The Return Type alone is insufficient to
distinguish two versions of a method in the
K. INDHU

DEFINITION- METHOD
OVERLOADING
THUS DEFINITION
of METHOD OVERLOADING>
Possessing 2 or more methods, with same
name but different signatures inside the same
class is called as METHOD OVERLOADING.
It is to be noted that Signature of method
includes(i) Parameter numbers,
(ii) Parameter Data Types and,
(iii) Order of Parameters.

K. INDHU

EXAMPLE- METHOD
OVERLOADING

THE FIRST VERSION OR OVERLOADED METHOD TAKES NO PARA

THE SECOND VERSION OR OVERLOADED METHOD TAKES ONE INTEGER

THE THIRD VERSION OR OVERLOADED METHOD TAKES 2 INT PAR

THE FOURTH VERSION OR OVERLOADED METHOD TAKES 1 DOUBL


K. INDHU

EXAMPLE- METHOD
OVERLOADING

K. INDHU

AUTOMATIC CONVERSIONS
OVERLOADING

K. INDHU

POLYMORPHISM

Method Overloading is an example for COMPILE


TIME POLYMORPHISM which is also termed as STATIC
BINDING.

Method overloading supports polymorphism because it


is one way that Java implements the one
interface, multiple methods paradigm.

EXAMPLE ->
1. Javas standard class library includes an absolute value
method, called abs( ).
2. This method is overloaded by Javas Math class to handle
all numeric types.
3. Java determines which version of abs( ) to call based
upon the type of argument.
K. INDHU

OVERLOADING CONSTRU

K. INDHU

OVERLOADING CONSTRU

K. INDHU

11

PASSING OBJECT AS
PARAMETER

K. INDHU

COPY 1 OBJECT INTO ANOTHER

There are many ways to copy the values of


one object into another in java. They are:(1) By constructor,

(2) By assigning the values of one object


into another,

(3) By clone() method of Object class.

K. INDHU

COPY OBJECT THRU


CONSTRUCTOR

K. INDHU

COPY OBJECT THRU


CONSTRUCTOR

K. INDHU

SO FAR WE STUDIED
Overloading

K. INDHU

HAPPY
LEARNING!!!

You might also like