1 / 3

Unit-1 Introduction to Java

Unit-1 Introduction to Java. Overloading. 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.

lynch
Download Presentation

Unit-1 Introduction to Java

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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.

More Related