and Answers All Correct
A special variable that holds a value being passed into a method is called what?
A) Modifier
B) Parameter
C) Alias
D) Argument - Answer-Answer: B
When you pass an argument to a method, be sure that the argument's data type is
compatible with:
A) the parameter variable's data type
B) the method's return type
C) the version of Java currently being used
D) IEEE standards - Answer-Answer: A
A parameter variable's scope is:
A) the method in which the parameter is declared
B) the class to which the method belongs
C) the main method
D) All of the above - Answer-Answer: A
The lifetime of a method's local variable is:
A) the duration of the program
B) the duration of the class to which the method belongs
C) the duration of the method that called the local variable's method
D) only while the method is executing - Answer-Answer: D
Local variables:
A) are hidden from other methods
B) may have the same name as local variables in other methods
C) lose the values stored in them between calls to the method in which the variable is
declared
D) All of the above - Answer-Answer: D
Which of the following values can be passed to a method that has an int parameter
variable?
A) float
, B) double
C) long
D) All of the above
E) None of the above - Answer-Answer: E
The header of a value-returning method must specify this.
A) The method's local variable names
B) The name of the variable in the calling program that will receive the returned value
C) The data type of the return value
D) All of the above - Answer-Answer: C
What will be returned from the following method?
public static double methodA()
{
double a = 8.5 + 9.5;
return a;
}
A) 18.0
B) 18 (as an integer)
C) 8
D) This is an error. - Answer-Answer: A
In a @return tag statement the description:
A) cannot be longer than one line
B) describes the return value
C) must be longer than one line
D) describes the parameter values - Answer-Answer: B
When a method tests an argument and returns a true or false value, it should return:
A) a zero for true and a one for false
B) a boolean value
C) a zero for false and a non-zero for true
D) a method should not be used for this type test - Answer-Answer: B
The phrase divide and conquer is sometimes used to describe:
A) the backbone of the scientific method
B) the process of dividing functions
C) the process of breaking a problem down into smaller pieces
D) the process of using division to solve a mathematical problem - Answer-Answer: C
In a general sense, a method is:
A) a plan
B) a statement inside a loop
C) a comment
D) a collection of statements that performs a specific task - Answer-Answer: D