Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a method named add that takes two integers and returns their sum.
Java
public int add(int a, int b) {
return a [1] b;
}🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
2fill in blank
mediumComplete the code to overload the add method to accept two double values and return their sum.
Java
public double add(double a, double b) {
return a [1] b;
}🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
3fill in blank
hardFix the error in the overloaded method that adds three integers.
Java
public int add(int a, int b, int c) {
return a [1] b [2] c;
}🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
4fill in blank
hardFill both blanks to create an overloaded method that concatenates two strings.
Java
public String add(String a, String b) {
return a [1] b;
}🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
5fill in blank
hardFill all three blanks to overload the add method for three double values.
Java
public double add(double a, double b, double c) {
return a [1] b [2] c;
}🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
