In: Computer Science
True/False
1. An automatic storage class variable is stored in the runtime stack
2. When a value parameter is passed to a function, the function called utilizes a copy of that parameter which is internal to the function called
3. When a reference parameter is passed to a function, the function called receives the memory address of that parameter and does not make a copy of it
4. Debug flags often control extra output to be printed conditionally
Multiple choice
1. An interactive debugger can be used to
a. set statements at which to pause the running program and examine critical variables
b. observe the flow of control as the program runs
c. set the values of critical variables during the actual run, and change them to look at what happens
d. all of the above
2. Debug flags in a program
a. should be removed before the next version is worked on, as they will annoy the future programmers
b. should be left in for the next version to be worked on, as they will help the new programmers to do future testing; they can be deactivated and activated as needed
c. should never be used as they cause extra lines in the code and that is not efficient
3. Black box testing is
a. when a programmer tests the code they write as they work on it
b. when a program development manager tests the code after it has been completely written
c. when a possible user of the code tests it by running and using it, without being able to see the actual code at all
d. when a program is released to the public and a very large group of users all test it at once in real life
4. When a function is called during program execution
a. an activation record is allocated on the runtime stack to store data needed by the function to execute
b. the compiler generates a stack frame in the source code
c. copies will be created of value parameters, and addresses will be stored for reference parameters, in the activation record for the function called
d. both a and c
5. Given the following for loop body, the value of count when the loop exits is
for (int count = 0; count < 10; count++) cout << count << endl;
a. 0 b. 9 c. 10 d. 11
6. The srand function (A) should be called before each call to rand( ) (B) should be used instead of rand( ) to generate truly random numbers(C) is unnecessary in C++ (D) can use the actual time from the hardware clockas a seed value
7. Which statement about the rand( ) function is false?(A) a call to rand( ) generates a value between INT_MIN and INT_MAX (B) the expression rand( ) % 5 always produces a value between 0 and 4 (C) the range of values generated by rand( ) is not always what is needed in a particular program (D) the prototype for rand( ) is in cstdlib
8. Most serious program bugs are the result of a. syntax errors b. semantic errors c. runtime errors d. typographical errors
True/False
1. An automatic storage class variable is stored in the runtime stack
True
2. When a value parameter is passed to a function, the function called utilizes a copy of that parameter which is internal to the function called
True
3. When a reference parameter is passed to a function, the function called receives the memory address of that parameter and does not make a copy of it
True
4. Debug flags often control extra output to be printed conditionally
False
Multiple choice
1. An interactive debugger can be used to
a. set statements at which to pause the running program and examine critical variables
b. observe the flow of control as the program runs
c. set the values of critical variables during the actual run, and change them to look at what happens
d. all of the above
Answer: d. all of the above
2. Debug flags in a program
a. should be removed before the next version is worked on, as they will annoy the future programmers
b. should be left in for the next version to be worked on, as they will help the new programmers to do future testing; they can be deactivated and activated as needed
c. should never be used as they cause extra lines in the code and that is not efficient
Answer: b. should be left in for the next version to be worked on, as they will help the new programmers to do future testing; they can be deactivated and activated as needed
3. Black box testing is
a. when a programmer tests the code they write as they work on it
b. when a program development manager tests the code after it has been completely written
c. when a possible user of the code tests it by running and using it, without being able to see the actual code at all
d. when a program is released to the public and a very large group of users all test it at once in real life
Answer: c. when a possible user of the code tests it by running and using it, without being able to see the actual code at all
4. When a function is called during program execution
a. an activation record is allocated on the runtime stack to store data needed by the function to execute
b. the compiler generates a stack frame in the source code
c. copies will be created of value parameters, and addresses will be stored for reference parameters, in the activation record for the function called
d. both a and c
Answer: d. both a and c
5. Given the following for loop body, the value of count when the loop exits is
for (int count = 0; count < 10; count++) cout << count << endl;
a. 0
b. 9
c. 10
d. 11
Answer: c. 10
6. The srand function
(A) should be called before each call to rand( )
(B) should be used instead of rand( ) to generate truly random numbers
(C) is unnecessary in C++
(D) can use the actual time from the hardware clockas a seed value
Answer: (B) should be used instead of rand( ) to generate truly random numbers
7. Which statement about the rand( ) function is false?
(A) a call to rand( ) generates a value between INT_MIN and INT_MAX
(B) the expression rand( ) % 5 always produces a value between 0 and 4
(C) the range of values generated by rand( ) is not always what is needed in a particular program
(D) the prototype for rand( ) is in cstdlib
Answer: (C) the range of values generated by rand( ) is not always what is needed in a particular program
8. Most serious program bugs are the result of
a. syntax errors
b. semantic errors
c. runtime errors
d. typographical errors
Answer: b. semantic errors