View Assessment Result: Multiple Choice Quiz 1



Your performance was as follows:

1.

One reason for using an assert statement such as

      assert( 0 <= i && i < 10 );

within code is to



(a) instruct the compiler to set i to any value in the indicated range
(b) provide a comment for the user
(c) send a warning message but continue execution when the condition is violated
(d) terminate execution and send an error message whenever the condition is violated

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



2.
Each of the following is a basic C++ type EXCEPT

(a) byte
(b) char
(c) bool
(d) unsigned int

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.
The value of the C++ expression 10/3 is

(a) 4
(b) 1
(c) 3
(d) 3.33333

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



4.
All of the following types can be used in a switch expression EXCEPT

(a) float
(b) int
(c) short
(d) enum

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.

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

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



6.
How does C++ handle memory allocation?

(a) Allocation and deallocation is the responsibility of the programmer.
(b) Allocation and deallocation is completely shielded from the programmer.
(c) C++ always uses a garbage collector.
(d) C++ has a garbage collector that can be used or turned off.

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



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) 15 5 11
(b) 15 6 10
(c) 16 5 11
(d) 16 6 10

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.
Each of the following programming styles is well supported by C++ EXCEPT

(a) object-based programming (as in Java)
(b) object-oriented programming (as in Java)
(c) functional programming (as in Lisp)
(d) procedural programming (as in Pascal)

Correct answer is (c)

Your score on this question is: 0.00

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



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

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

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



10.

Which of the following descriptions of C++ are true?

  1. It is a small, tidy language like C.
  2. It is a teaching language like Pascal.
  3. It is a safe, garbage collected language like Java.


(a) I only
(b) III only
(c) None
(d) I and II

Correct answer is (c)

Your score on this question is: 0.00

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



Go to top of assessment.

Total score: 80.00