Method overloading

Page 1

Method Overloading Tccicomputercoaching.com Java is a high-level programming language originally developed by Sun Microsystems and released in 1995. Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX. This tutorial gives a complete understanding of Java. Java supports object oriented concepts like inheritance, Polymorphism, Data Abstraction, Encapsulation etc‌‌. Polymorphism means more than one form. It contains method overloading in Java. What is Method Overloading? If a class have multiple methods by same name but different parameters, it is known as Method Overloading. Why do we use Method Overloading? If we have to perform only one operation, having same name of the methods increases the readability of the program. Suppose you have to perform addition of the given numbers but there can be any number of arguments, if you write the method such as a(int,int) for two parameters, and b(int,int,int) for three parameters then it may be difficult for you as well as other programmers to understand the behaviour of the method because its name differs. So, we perform method overloading to figure out the program quickly. But there are some rules to be followed: Must change the argument list Can change the return type Can change the access modifier Can declare new or broader checked exception Different ways to overload the method

There are two ways to overload the method in java


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.
Method overloading by Rosario Riley - Issuu