010-001-008
Method Overloading: Parameter Count
Easy
Problem Description
Method Overloading: Parameter Count
Learning Objective: Understand method overloading with different parameter counts
Create two greeting method versions. Define both 1-parameter version (name only) and 2-parameter version (name + age).
Input
Line 1: Name 1 (string)
Line 2: Name 2 (string)
Line 3: Age (integer)
Output
Hello, [name1]!
Hello, [name2]! You are [age] years old.
Test Cases
※ Output examples follow programming industry standards
Input:
Taro Hanako 25
Expected Output:
Hello, Taro! Hello, Hanako! You are 25 years old.
Input:
Ichiro Jiro 30
Expected Output:
Hello, Ichiro! Hello, Jiro! You are 30 years old.
Input:
A B 0
Expected Output:
Hello, A! Hello, B! You are 0 years old.
❌ Some tests failed
Your Solution
Current Mode:● My Code
99
1
2
3
4
5
6
7
8
9
10
›
⌄
⌄
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
