Complete the code to define a method named add that takes two integers and returns their sum.
public int add(int a, int b) {
return a [1] b;
}The add method should return the sum of a and b. The plus sign + adds two numbers.
Complete the code to overload the add method to accept two double values.
public double add(double a, double b) {
return a [1] b;
}The overloaded add method should add two double values using the + operator.
Fix the error in the method signature to correctly overload the add method with three integer parameters.
public int add(int a, int b, [1] c) { return a + b + c; }
The method overload requires three integer parameters, so the third parameter must be int.
Fill both blanks to create two overloaded multiply methods: one for two integers and one for two doubles.
public int multiply(int a, int b) {
return a [1] b;
}
public double multiply(double a, double b) {
return a [2] b;
}Both methods multiply their parameters using the * operator.
Fill all three blanks to create overloaded concatenate methods: one for two strings, one for three strings, and one for an array of strings.
public String concatenate(String a, String b) {
return a [1] b;
}
public String concatenate(String a, String b, String c) {
return a [2] b [3] c;
}String concatenation in Java uses the + operator to join strings.