010-003-011

Overloading by Parameter Type

Easy

Problem Description

Overloading by Parameter Type

In this problem, you will create a program that defines three overloaded display methods with different parameter types (int, double, and String), calls each with its corresponding value, and displays the result to standard output.

Learning Objective: Understand how to overload methods by varying parameter types

Overview

In method overloading, methods with different parameter types can have the same name. The compiler automatically selects the appropriate method based on the argument type.

Specifications

  • Define three display methods:
    • display(int value): displays "Integer: " + value
    • display(double value): displays "Double: " + value
    • display(String value): displays "String: " + value
  • Call with each type's value

Output Format

Integer: 42
Double: 3.14
String: Hello

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