0
0
Javaprogramming~15 mins

Method parameters 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 that takes one integer parameter.

Java
public void printNumber([1] number) {
    System.out.println(number);
}
🎯 Drag options to blanks, or click blank then click option
Aint
Bdouble
CString
Dboolean
Attempts:
3 left
2fill in blank
medium

Complete the code to call the method with the correct argument.

Java
printNumber([1]);
🎯 Drag options to blanks, or click blank then click option
A"5"
B5
Ctrue
D5.0
Attempts:
3 left
3fill in blank
hard

Fix the error in the method declaration to accept two parameters: an integer and a string.

Java
public void display([1] number, String text) {
    System.out.println(number + ": " + text);
}
🎯 Drag options to blanks, or click blank then click option
Aint
Bdouble
Cboolean
DString
Attempts:
3 left
4fill in blank
hard

Fill both blanks to declare a method that takes a double and a boolean parameter.

Java
public void setValues([1] value, [2] flag) {
    System.out.println(value + ", " + flag);
}
🎯 Drag options to blanks, or click blank then click option
Adouble
Bint
Cboolean
DString
Attempts:
3 left
5fill in blank
hard

Fill all three blanks to declare a method that takes a String, an int, and a boolean parameter.

Java
public void update([1] name, [2] age, [3] active) {
    System.out.println(name + ", " + age + ", " + active);
}
🎯 Drag options to blanks, or click blank then click option
Aint
Bboolean
CString
Ddouble
Attempts:
3 left