010-001-008
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 — a 1-parameter version (name only) and a 2-parameter version (name and age) — calls each appropriately, and displays the results 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.
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