Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a method named greet that returns nothing.
Java
public [1] greet() { System.out.println("Hello!"); }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
2fill in blank
mediumComplete the code to declare a method named add that returns an integer.
Java
public [1] add(int a, int b) { return a + b; }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
3fill in blank
hardFix the error in the method declaration to make it valid.
Java
public [1] calculateSum(int a, int b) { return a + b; }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
4fill in blank
hardFill both blanks to declare a method named multiply that returns the product of two doubles.
Java
public [1] multiply([2] a, [2] b) { return a * b; }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
5fill in blank
hardFill all three blanks to declare a method named isEven that returns true if a number is even.
Java
public [1] isEven([2] num) { return num [3] 2 == 0; }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
