Presentation is loading. Please wait.

Presentation is loading. Please wait.

Unit-1 Introduction to Java

Similar presentations


Presentation on theme: "Unit-1 Introduction to Java"— Presentation transcript:

1 Unit-1 Introduction to Java
Overloading

2 Overloading Overloading is a mechanism in which we can use many methods having the same function name but can pass different number of parameters or different types of parameters. If you call max with int parameters, the max method that expects int parameters will be invoked; if you call max with double parameters, the max method that expects double parameters will be invoked.

3 Can you invoke the max method with an int value and a double value, such as max(2, 2.5)? If so, which of the max methods is invoked? The answer to the first question is yes. The answer to the second is that the max method for finding the maximum of two double values is invoked. The argument value 2 is automatically converted into a double value and passed to this method.


Download ppt "Unit-1 Introduction to Java"

Similar presentations


Ads by Google