010-002-009

Overloading by Argument Count

Easy

Problem Description

Overloading by Argument Count

In this problem, you will create a program that reads a name from standard input, defines two overloaded greet methods — one with no arguments and one accepting a String parameter — calls both methods, and displays the greeting messages to standard output.

Learning Objective: Understand method overloading with different argument counts

Overview

Define methods with the same name but different numbers of arguments.

Input

name (String)

Specifications

  • greet() method: outputs "Hello!"
  • greet(String name) method: outputs "Hello, [name]!"
  • Read a name from standard input and call both methods

Output Format

Hello!
Hello, [name]!

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