NEW
Font size
WorksheetsMethods Quiz
Total questions: 10
Worksheet time: 5mins
Suppose your method does not return any value, which of the following keywords can be used as a return type?
void
int
double
public
The signature of a method consists of .
method name
method name and parameter list
return type, method name, and parameter list
parameter list
When you invoke a method with a parameter, the value of the argument is passed to the parameter. This is referred to as .
method invocation
pass by value
pass by reference
pass by name
What is the correct syntax to declare a method named displayMessage that takes no parameters and returns nothing?
public displayMessage()
public void displayMessage()
void displayMessage(void)
function displayMessage()
What is the purpose of the return statement in a method?
To end a loop
To exit the method and send a value back
To define a variable
To call another method
Which of the following is NOT a valid method name in Java?
getSum
_findTotal
2calculate
computeAverage
Which of the following statements correctly defines a method that receives an integer and returns a double?
double calc(int x)
void calc(double x)
int calc(double x)
calc(int x)
What happens if a method specifies a return type but does not include a return statement?
The compiler automatically returns zero
The program runs normally
A compile-time error occurs
It returns null
What is method overloading?
Defining two or more methods with the same name but different parameter lists
Using too many methods in one class
Calling one method from another
Writing a method that has too many parameters
Which of the following statements about methods is true?
A method can be called multiple times in a program
Methods can only be used once
Every method must return a value
Methods cannot take parameters
