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]

Test Cases

※ Output examples follow programming industry standards

Input:
10
20
30
Expected Output:
Two args: 30
Three args: 60
Input:
5
5
5
Expected Output:
Two args: 10
Three args: 15
Input:
0
0
0
Expected Output:
Two args: 0
Three args: 0
Input:
5
15
25
Expected Output:
Two args: 20
Three args: 45
❌ Some tests failed
❌ エラー発生

Your Solution

Current Mode: My Code
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here

sc.close();
}
}
0 B / 5 MB

You have 9 free executions remaining