c. The program runs fine but displays things other than 5.
d. The program does not compile.
#
6 A variable defined inside a method is referred to as __________.
A. a local variable
B. a block variable
C. a global variable
D. a method variable
#
7 When you invoke a method with a parameter, the value of the argument is
passed to the parameter. This is referred to as _________.
A. pass by name
B. pass by value
C. pass by reference
D. method invocation
#
8 Which of the following should be declared as a void method?
A. Write a method that returns a random integer from 1 to 100.
B. Write a method that prints integers from 1 to 100.
C. Write a method that checks whether current second is an integer from 1 to
60.
D. Write a method that converts an uppercase letter to lowercase.
#
9 Each time a method is invoked, the system stores parameters and local
variables in an area of memory, known as _______, which stores elements in
last-in first-out fashion.
A. storage area
B. a heap
C. a stack
D. an array
#
10. What is the output of the following code?
public class Test {
public static void main(String[] args) {
System.out.println(m(“ABCDEFG”));
}
public static String m(String s) {
return s.substring(0, 3) + s.substring(5);
}
}
a. ABCEG
b. ABCFG
c. ABCEFG