Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a static method named greet.
Java
public class Hello { public static void [1]() { System.out.println("Hello, world!"); } }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
2fill in blank
mediumComplete the code to call the static method greet from the main method.
Java
public class Hello { public static void greet() { System.out.println("Hello, world!"); } public static void main(String[] args) { [1](); } }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
3fill in blank
hardFix the error in calling the static method greet from another class named App.
Java
public class Hello { public static void greet() { System.out.println("Hello from Hello class!"); } } public class App { 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 create a static method square that returns the square of an integer.
Java
public class MathUtils { public static int [1](int num) { return num [2] num; } }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
5fill in blank
hardFill all three blanks to create a static method isEven that returns true if a number is even, otherwise false.
Java
public class NumberUtils { public static boolean [1](int n) { return n [2] 2 [3] 0; } }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
