0
0
Javaprogramming~15 mins

Method declaration in Java - Interactive Code Practice

Choose your learning style8 modes available
ads_clickPractice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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
Avoid
BString
Cint
Dclass
Attempts:
3 left
2fill in blank
medium

Complete 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
Avoid
BString
Cdouble
Dint
Attempts:
3 left
3fill in blank
hard

Fix 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
Avoid
BcalculateSum
Cint
Dsum
Attempts:
3 left
4fill in blank
hard

Fill 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
Adouble
Bint
Cfloat
DString
Attempts:
3 left
5fill in blank
hard

Fill 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
Aboolean
Bint
C%
Ddouble
Attempts:
3 left