010-004-011

Overloaded print Methods

Easy

Problem Description

Overloaded print Methods

In this problem: You will define three print methods with different parameter types (print(String), print(int), print(double)), call each one, and display the results to standard output.

Learning Objective: Understand the basics of method overloading and learn to define and call methods with the same name but different parameter types

Overview

In Java, you can define multiple methods with the same name as long as the parameter types or counts differ. This is called method overloading. In this problem, you will define the print method with three different parameter types and observe how the compiler selects the correct method.

Specifications

  1. print(String value) - Output the value prefixed with String:
  2. print(int value) - Output the value prefixed with int:
  3. print(double value) - Output the value prefixed with double:
  4. Call all three methods from the main method

Output Format

String: Hello
int: 42
double: 3.14

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