010-002-003
Overloading: Distinguish by Argument Count
Easy
Problem Description
Overloading: Distinguish by Argument Count
In this problem, you will create a program that defines two overloaded add methods—one accepting 2 arguments and one accepting 3 arguments—and displays the sum of each call to standard output.
Learning Objective: Understand overloaded methods with different argument counts
Define two add methods with the same name but different argument counts (2 and 3). Java automatically selects which method to call based on argument count.
Input
Line 1: First number (integer)
Line 2: Second number (integer)
Line 3: Third number (integer)
Output
Two args: [first+second]
Three args: [first+second+third]
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up