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, calls each one, and displays the results to standard output.
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
- 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
Output Format
Hello, World!
Hello, Alice!
Hello, Bob!
Hello, Bob!
Hello, Bob!
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