NEW
Font size
WorksheetsTopic 8-2: Method
Total questions: 9
Worksheet time: 8mins
Write a method header to return a square root of a number
public static void double sqrt(value)
public static void double sqrt(double value)
public static double sqrt(value)
public static double sqrt(double value)
Write a method header to test whether a number is even, and returns true if it is
public static boolean isEven(int value)
public static void isEven(int value)
public static int isEven(int value)
public static void boolean (int value)
Can we use "void" and "return" together?
Yes
No
How many values can a method return?
0
1
2
infinite
Which of these is a method with four parameters?
public void math(int a, int b)
public void math(double a, double b, double c, double d)
public void math(a, b, c, d)
public void math(4, 3, 2, 1)
What is the output of this code?
Error
Hi Adila (12345)
Adila 12345
display
What is the error in this code?
No error
Incorrect method header - public static String getSentence
Parameters arrangement in getSentence(id, name)
return statement
Fix the error by replacing with the correct java statement.
public static String getSentence(int id, String name)
public static String getSentence(String name, int id)
public static void getSentence(String name, int id)
public static int getSentence(int id, String name)
What is the output of this code?
Error
Second method
Third method
Hi Adila (12345)
