All

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)

Try for Free
010-002-001

Method Overloading: Score Aggregation

# <a href="https://javadrill.tech/problems/010"><a href="https://javadrill.tech/problems/008">method...

Try for Free
010-002-002

Method Overloading: Tax Calculation

# <a href="https://javadrill.tech/problems/010"><a href="https://javadrill.tech/problems/008">method...

010-002-003

Overloading: Distinguish by Argument Count

# Overloading: Distinguish by Argument Count **In this problem**, you will create a program that de...

010-002-004

Distinction by Parameter Count: Add Method

<h2>Overloading by Parameter Count</h2><p><strong>In this problem</strong>, you will create a progra...

010-002-005

Overloading: Distinction by Parameter Count

# Overloading: Distinction by Parameter Count ## Learning Objective Learn <a href="https://javadril...

010-002-006

Method Overloading: Tax Calculation

# <a href="https://javadrill.tech/problems/010"><a href="https://javadrill.tech/problems/008">method...

010-002-007

Method Overloading: Score Aggregation

# <a href="https://javadrill.tech/problems/010"><a href="https://javadrill.tech/problems/008">method...

010-002-008

Method Overload: Type-Based Dispatch

# <a href="https://javadrill.tech/problems/008">method</a> Overload: Type-Based Dispatch **In this ...

010-002-009

Overloading by Argument Count

# Overloading by Argument Count **In this problem**, you will create a program that reads a name fr...

010-002-010

Emulating Default Values

# Emulating Default Values **In this problem**, you will create a program that reads values from st...

010-002-011

Overloading by Parameter Count

# Overloading by Parameter Count **In this problem**, you will create a program that overloads the ...

010-002-012

Overloading with Varargs

# Overloading with Varargs **In this problem**, you will create a program that reads integers from ...