Programming Logic and Design
Chapter 9 Review AND Vocabulary
Complete Answers
7. When you use a variable name in a method call, it______________as the variable
in the method header.
a. can have the same name
b. cannot have the same name
c. must have the same name
d. cannot have the same data type - ANSWER-a. can have the same name
8. Assume that you have written a method with the header void myMethod(num a,
string b). Which of the following is a correct method call?
a. myMethod(12)
b. myMethod(12, "Hello")
c. myMethod("Goodbye")
d. It is impossible to tell. - ANSWER-b. myMethod(12, "Hello")
9. Assume that you have written a method with the header num yourMethod(string
name, num code). The method's type is__________.
a. num
b. string
c. num and string
d. void - ANSWER-a. num
10. Assume that you have written a method with the header string myMethod(num
score, string grade). Also assume that you have declared a numeric variable named
test. Which of the following is a correct method call?
a. myMethod()
b. myMethod(test)
, c. myMethod(test, test)
d. myMethod(test, "A") - ANSWER-d. myMethod(test, "A")
11. The value used in a method's return statement must__________.
a. be numeric
b. be variable
c. match the data type used before the method name in the header
d. two of the above - ANSWER-c. match the data type used before the method name
in the header
12. When a method receives a copy of the value stored in an argument used in the
method call, it means the variable was____________. b
a. unnamed
b. passed by value
c. passed by reference
d. assigned its original value when it was declared - ANSWER-b. passed by value
13. A void method_______________.
a. contains no statements
b. requires no parameters
c. returns nothing
d. has no name - ANSWER-c. returns nothing
14. When an array is passed to a method, it is____________.
a. passed by reference
b. passed by value
c. unnamed in the method
d. unalterable in the method - ANSWER-a. passed by reference
15. When you overload a method, you write multiple methods with the
same_________________.
a. name
Chapter 9 Review AND Vocabulary
Complete Answers
7. When you use a variable name in a method call, it______________as the variable
in the method header.
a. can have the same name
b. cannot have the same name
c. must have the same name
d. cannot have the same data type - ANSWER-a. can have the same name
8. Assume that you have written a method with the header void myMethod(num a,
string b). Which of the following is a correct method call?
a. myMethod(12)
b. myMethod(12, "Hello")
c. myMethod("Goodbye")
d. It is impossible to tell. - ANSWER-b. myMethod(12, "Hello")
9. Assume that you have written a method with the header num yourMethod(string
name, num code). The method's type is__________.
a. num
b. string
c. num and string
d. void - ANSWER-a. num
10. Assume that you have written a method with the header string myMethod(num
score, string grade). Also assume that you have declared a numeric variable named
test. Which of the following is a correct method call?
a. myMethod()
b. myMethod(test)
, c. myMethod(test, test)
d. myMethod(test, "A") - ANSWER-d. myMethod(test, "A")
11. The value used in a method's return statement must__________.
a. be numeric
b. be variable
c. match the data type used before the method name in the header
d. two of the above - ANSWER-c. match the data type used before the method name
in the header
12. When a method receives a copy of the value stored in an argument used in the
method call, it means the variable was____________. b
a. unnamed
b. passed by value
c. passed by reference
d. assigned its original value when it was declared - ANSWER-b. passed by value
13. A void method_______________.
a. contains no statements
b. requires no parameters
c. returns nothing
d. has no name - ANSWER-c. returns nothing
14. When an array is passed to a method, it is____________.
a. passed by reference
b. passed by value
c. unnamed in the method
d. unalterable in the method - ANSWER-a. passed by reference
15. When you overload a method, you write multiple methods with the
same_________________.
a. name