Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to call the method greet.
Java
public class Main { public static void greet() { System.out.println("Hello!"); } public static void main(String[] args) { [1]; } }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
2fill in blank
mediumComplete the code to call the method add with arguments 5 and 3.
Java
public class Calculator { public static int add(int a, int b) { return a + b; } public static void main(String[] args) { int result = [1]; System.out.println(result); } }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
3fill in blank
hardFix the error in calling the method printMessage.
Java
public class Messenger { public static void printMessage(String msg) { System.out.println(msg); } public static void main(String[] args) { [1]; } }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
4fill in blank
hardFill both blanks to call the method multiply with arguments 4 and 7 and store the result.
Java
public class MathOps { public static int multiply(int x, int y) { return x * y; } public static void main(String[] args) { int product = [1]; System.out.println([2]); } }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
5fill in blank
hardFill all three blanks to call concat method with two strings and print the result.
Java
public class StringOps { public static String concat(String a, String b) { return a + b; } public static void main(String[] args) { String result = [1]; System.out.println([2]); System.out.println([3]); } }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
