010-001-012
Method Overloading Basics
Easy
Problem Description
method overloading Basics
In this problem, you will create a program that defines three greet methods with the same name but different parameters, reads a name and count from standard input, and calls each method.
Learning Objective: Understand the concept of overloading by defining methods with the same name but different parameters
Overview
Method overloading is defining multiple methods with the same name in the same class. If the number or types of parameters differ, the compiler automatically selects the appropriate method.
Specifications
- Read the following from standard input:
- Line 1: name (String)
- Line 2: repeat count (int)
- Define three greet methods:
- greet(): displays "Hello, World!"
- greet(String name): displays "Hello, " + name + "!"
- greet(String name, int times): displays greeting to name times times
- Call each method in this order
Input Format
name
count
Output Format
Hello, World!
Hello, [name]!
Hello, [name]!
... (count times)
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