View Assessment Result: Multiple Choice Quiz 1



Your performance was as follows:

1.
Which of the following derived types is significantly different with respect to the other three?

(a) array
(b) function
(c) union
(d) structure

Correct answer is (b)

Your score on this question is: 10.00

Feedback:
   See section 1.1.1 of the course notes.
   (b) No Feedback



2.
Which of the following statements can be used to exit from a loop?

(a) break;
(b) continue;
(c) return;
(d) exit(0);

Correct answer is (a)

Your score on this question is: 10.00

Feedback:
   See section 1.1.1 of the course notes.
   (a) No Feedback



3.

Under the declaration,

      int  n = 10;

which of the following loop constructs executes statement n times?



(a) do statement while( n-- );
(b) while( --n ) statement;
(c) for( int i = 1; i < n; i++ ) statement;
(d) while( n-- ) statement;

Correct answer is (d)

Your score on this question is: 10.00

Feedback:
   See section 1.1.1 of the course notes.
   (d) No Feedback



4.

Consider the following code fragment.

      bool  b = false;
      int   f( int x ) { ... }
      cout << f(b) << endl;

Which of the following is true?



(a) This will compile and execute properly in part because in the function call the bool will be converted to an int.
(b) This will not compile.
(c) This will compile and execute properly in part because in the function call both bool and int are built-in types.
(d) This will compile and execute properly in part because in the function call the types match exactly.

Correct answer is (a)

Your score on this question is: 10.00

Feedback:
   See section 1.1.1 of the course notes.
   (a) No Feedback



5.
Which of the following control structures can lead to non-terminating behavior?

(a) A while loop
(b) A switch statement
(c) An if-else statement
(d) A return statement

Correct answer is (a)

Your score on this question is: 10.00

Feedback:
   See section 1.1.1 of the course notes.
   (a) No Feedback



6.
Assume that Thing is a user-defined type. Which of the following print functions for Thing is the safest and most efficient?

(a) void print( Thing* x );
(b) void print( Thing& x );
(c) void print( Thing x );
(d) void print( const Thing& x );

Correct answer is (d)

Your score on this question is: 10.00

Feedback:
   See section 1.1.1 of the course notes.
   (d) No Feedback



7.

The "maximal munch rule" for compilers is to read as many characters as can possibly be assembled into a meaningful syntactic construct. Consider the following code fragment.

      int a = 5; int b = 10;
        cout << (a+++b) << " ";
      cout << a << " " << b << endl;

If the C++ compiler follows the maximal munch rule, what is printed as a result of the code fragment?



(a) 16 6 10
(b) 15 6 10
(c) 16 5 11
(d) 15 5 11

Correct answer is (b)

Your score on this question is: 10.00

Feedback:
   See section 1.1.1 of the course notes.
   (b) No Feedback



8.
Which of the following lists of C++ types are ordered increasingly by size, as computed by sizeof() ?

(a) short, char, int, long
(b) char, short, int, long
(c) long, int, char, short
(d) long, int, short, char

Correct answer is (b)

Your score on this question is: 10.00

Feedback:
   See section 1.1.1 of the course notes.
   (b) No Feedback



9.
Which of the following expressions evaluates to true in C++ if and only if the index variable i is in bounds for an array of size 10?

(a) 0 <= i < 10
(b) 0 < 10
(c) 0 <= i && i < 10
(d) 0 <= i && i <= 10

Correct answer is (c)

Your score on this question is: 10.00

Feedback:
   See section 1.1.1 of the course notes.
   (c) No Feedback



10.
Which company was responsible for the development of C++?

(a) Microsoft
(b) AT&T
(c) SUN
(d) IBM

Correct answer is (b)

Your score on this question is: 10.00

Feedback:
   See section 1.1.1 of the course notes.
   (b) No Feedback



Go to top of assessment.

Total score: 100.00