010-004-009

Practical Overloading Example

Easy

Problem Description

Practical Overloading Example

In this problem, you will create a program that implements two overloaded log methods sharing the same name, reading values from standard input and displaying log output.

Learning Objective: Understand practical applications of overloading

Overview

Design flexible log output methods using overloading.

Specifications

  • log(String message) method: outputs in "[INFO] message" format
  • log(String level, String message) method: outputs in "[level] message" format
  • Call both methods

Input Format

Line 1: message to output at INFO level
Line 2: log level to use (e.g. ERROR, WARN, DEBUG)
Line 3: message to output at the specified level

Output Format

[INFO] <line 1 input>
[<line 2 input>] <line 3 input>

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