010-004-007
Method Overload: Return Type Differences
Medium
Problem Description
Method Overload: Return Type Differences
Learning Objective: Understand the role of return types in overloading and design methods correctly
Overview
Method overloading requires different parameters. Methods that differ only in return type cannot be overloaded. In this problem, implement two getValue methods that differ in both parameters and return types.
Specifications
- getValue method (no arguments): Returns string "Default"
- getValue method (boolean argument): Returns integer 1 for true, 0 for false
- Call different methods with different return types based on arguments
Input
Line 1: boolean value (true or false)
Output Format
String value: Default
Int value: (1 if input is true, 0 if false)
Sample I/O
Input:
true
Output:
String value: Default
Int value: 1
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