Lesson 10 - Activity 1 - Can you overload a method?

Time: 15 minutes

Purpose: This activity helps you get familiar with overloading

Introduction: Youโ€™re had experience creating methods, now have a go at overloading them

Task: Building on โ€“ create an add method that takes three integers, and returns an integer value.

Use overloading, and attempt to make use of your previous methods.

public static int add (int num1, int num2, int num3) {
    int answer = (num1 + num2 + num3);
    return answer;
}
1 Like

That will work - the () around num1 + num2 + num3 arenโ€™t required. But good work.