Sie sind auf Seite 1von 2

CS 012 Intro to Computer Science II Quiz 3 Section 002 Friday 4/15

Each question is worth 1 point.

Spring - 2005

SOLUTION

1. Connecting all object files together to form an executable file is called


a. assembling b. linking c. compiling d. debugging

2. If x is negative, the following statement assert(x >= 0);


e. terminates the program, displays the file name, line number, and expression. f. does nothing. g. outputs a warning and continues executing the program. h. outputs a warning, sets x equal to 0 and continues executing the program. i. returns the value false.

3. Regression testing refers to


j. Never throwing away a test k. Never throwing away a version of your code l. Testing your code one function or class at a time m. Using a test harness n. A psychological analysis of your code

4. What values should you choose when testing a function you wrote?
o. Values that think will succeed p. Values that think will fail q. Values that are border cases r. Randomly generated values s. All of the above

5. A pointer variable can contain:


t. The address of a valid object or variable u. The value NULL v. The address of a deleted object w. A random address value x. All of the above y. A, B or D

6. Which of the following assigns the address of value to the pointer p1?
z. *p1 = &value; aa. p1 = value; bb. p1 = &value; cc. &p1 = *value;

7. What is the output of the following code fragment? int* p1 = NULL ; int* p2 = NULL ; *p1 = 3 ; *p2 = 5 ; p2 = p1 ; cout << *p2 << endl ;
dd. 3 ee. 5 ff. NULL gg. This is an error, a segmentation fault

8. What is the output of the following code? int *p1, *p2; p1 = new int; p2 = new int; *p1=11; *p2=0; p2=p1; cout << *p1 <<" " << *p2 << endl;
hh. 0 11 ii. 11 0 jj. 0 0 kk. 11 11 ll. Error, this is a segmentation fault

9. What is the output of the following code fragment? int v1=2, v2=-1; int* p1; int* p2; p1 = &v1; p2 = &v2; p2 = p1; cout << *p2 << endl;
mm. 2 nn. -1 oo. -2 pp. 1

10. Given that p1 is a pointer to a string, which of the following are legal statements?
qq. p1 = new int; rr. cout << *p1; ss. p1 = new char[10]; tt. *p1 = new string; uu. all of the above vv. B and D

Das könnte Ihnen auch gefallen