Type Promotion
010-002 - Type Promotion
The most basic form of overloading is varying the number of parameters. For example, you can create variations of a calculation method that accept one, two, or three values.
Practical examples:
- A method processing one value
- A method processing two values
- A method processing multiple values
This allows the caller to automatically select the appropriate method based on the number of arguments needed.
Example:
public int sum(int a) { return a; }
public int sum(int a, int b) { return a + b; }
public int sum(int a, int b, int c) { return a + b + c; }
Problems (12)
Method Overloading: Score Aggregation
# <a href="https://javadrill.tech/problems/010"><a href="https://javadrill.tech/problems/008">method...
Method Overloading: Tax Calculation
# <a href="https://javadrill.tech/problems/010"><a href="https://javadrill.tech/problems/008">method...
Overloading: Distinguish by Argument Count
# Overloading: Distinguish by Argument Count **In this problem**, you will create a program that de...
Distinction by Parameter Count: Add Method
<h2>Overloading by Parameter Count</h2><p><strong>In this problem</strong>, you will create a progra...
Overloading: Distinction by Parameter Count
# Overloading: Distinction by Parameter Count ## Learning Objective Learn <a href="https://javadril...
Method Overloading: Tax Calculation
# <a href="https://javadrill.tech/problems/010"><a href="https://javadrill.tech/problems/008">method...
Method Overloading: Score Aggregation
# <a href="https://javadrill.tech/problems/010"><a href="https://javadrill.tech/problems/008">method...
Method Overload: Type-Based Dispatch
# <a href="https://javadrill.tech/problems/008">method</a> Overload: Type-Based Dispatch **In this ...
Overloading by Argument Count
# Overloading by Argument Count **In this problem**, you will create a program that reads a name fr...
Emulating Default Values
# Emulating Default Values **In this problem**, you will create a program that reads values from st...
Overloading by Parameter Count
# Overloading by Parameter Count **In this problem**, you will create a program that overloads the ...
Overloading with Varargs
# Overloading with Varargs **In this problem**, you will create a program that reads integers from ...
