Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a method that prints a greeting.
Java
public class HelloWorld { public static void [1]() { System.out.println("Hello, world!"); } public static void main(String[] args) { greet(); } }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
2fill in blank
mediumComplete the code to call the method that calculates the sum.
Java
public class Calculator { public static int sum(int a, int b) { return a + b; } public static void main(String[] args) { int result = [1](5, 3); System.out.println(result); } }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
3fill in blank
hardFix the error by completing the method call correctly.
Java
public class Printer { public static void printMessage(String message) { System.out.println(message); } public static void main(String[] args) { [1]("Welcome!"); } }
🎯 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 the square of a number and call it.
Java
public class MathUtils { public static int [1](int num) { return num [2] num; } public static void main(String[] args) { int sq = square(4); System.out.println(sq); } }
🎯 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 checks if a number is even and call it.
Java
public class NumberCheck { public static boolean [1](int n) { return n [2] 2 [3] 0; } public static void main(String[] args) { boolean result = isEven(10); System.out.println(result); } }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
