Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to return the sum of two numbers.
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 method to return the length of the input string.
Java
public int getLength(String text) {
return text.[1]();
}🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
3fill in blank
hardFix the error in the method to correctly return the maximum of two numbers.
Java
public int max(int x, int y) { if (x > y) { return [1]; } else { return y; } }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
4fill in blank
hardFill both blanks to create a method that returns true if a number is even.
Java
public boolean isEven(int num) {
return num [1] 2 [2] 0;
}🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
5fill in blank
hardFill all three blanks to create a method that returns a new string with the first letter capitalized.
Java
public String capitalize(String word) {
return word.[1](0, 1).[2]() + word.[3](1);
}🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
