View Assessment Result: Multiple Choice Quiz 1



Your performance was as follows:

1.
Assuming that Thing is some user-defined type, which of the following functions uses the least useful parameter list?

(a) bool f( Thing& x ); save space and permit f() to easily mutate the object
(b) bool f( const Thing x ); f() gets its own copy of x, but is unable to mutate it.
(c) bool f( const Thing& x ); save space and protect the integrity of the object
(d) bool f( Thing x ); give f() its own copy of x to work with.

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 derived types is significantly different with respect to the other three?

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

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



3.

Suppose inf is an available ifstream and c is an available character. Consider the following code fragment.

do
    c = inf.get();
while (!inf.eof() && isspace(c));

Which of the following accurately describes the effect of executing this fragment?



(a) Characters are read until the end of the file is reached.
(b) Characters are read until a non-white-space character is read or until the end of the file is reached.
(c) Characters are read until a white space is read.
(d) The number of non-white-space characters is counted.

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



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

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



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

(a) A while loop
(b) An if-else statement
(c) A switch 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.
Which of the following is true about the default parameter passing mechanism in C++ ?

(a) It is call-by-reference.
(b) It is chosen automatically by the compiler.
(c) It is call-by-value.
(d) It depends on where the function is defined.

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



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

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



8.
Which of the following statements uses the C++ pre-increment operator?

(a) x += y;
(b) x = ++y;
(c) x = y++;
(d) x = y+y;

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.
The signature of a function is

(a) the name of the function and its parameter list
(b) the name of the function
(c) the body of the function
(d) the number of parameters

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



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) None
(b) I only
(c) I and II
(d) III only

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



Go to top of assessment.

Total score: 100.00