010-001-002
Method Overloading: Parameter Count
Easy
Problem Description
method overloading: Parameter Count
Learning Objective: Understand method overloading with different parameter counts
In this problem, you will create a program that defines two overloaded greet methods with different parameter counts — one for name only and one for name plus age — and displays the resulting greetings to standard output.
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.
Input:
Alice Bob 18
Expected Output:
Hello, Alice! Hello, Bob! You are 18 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
