View Assessment Result: Multiple Choice Quiz 3



Your performance was as follows:

1.
To which of the following is object-based programming ideally suited?

(a) Implementing simple monolithic programs
(b) Encapsulation
(c) Attaining the highest possible efficiency
(d) Providing elegant mechanisms for code reuse

Correct answer is (b)

Your score on this question is: 10.00

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



2.
Suppose a user-defined class Thing has a simple constructor that does not require any calls to new. Which of the following is true about the destructor?

(a) In this case, no destructor is required for class Thing.
(b) It might contain calls to delete, but might not.
(c) The appropriate destructor will be provided automatically by the compiler.
(d) It will not contain calls to delete.

Correct answer is (b)

Your score on this question is: 10.00

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



3.
Of the following methods, which is least important in a user-defined class with value semantics?

(a) A copy constructor
(b) The assignment operator
(c) The output operator
(d) A destructor

Correct answer is (c)

Your score on this question is: 10.00

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



4.
If a user-defined class Complex has overloaded operator+=, then one would expect this operator to have which of the following declarations?

(a) void operator+=( float real, float imag );
(b) Complex& operator+=( const Complex& rhs );
(c) Complex& operator+=( const Complex rhs );
(d) void operator+=( const Complex& rhs );

Correct answer is (b)

Your score on this question is: 10.00

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



5.
If a user-defined class overloads both operator== and operator<, which other operator, if any, is implicitly overloaded as a consequence?

(a) No other operator
(b) operator<<
(c) operator<=
(d) operator!=

Correct answer is (a)

Your score on this question is: 10.00

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



6.
What is the difference between a C++ class and a C++ struct ?

(a) The default access in a class is private and in a struct is public.
(b) The default access in a class is public and in a struct is private.
(c) Structs cannot contain function members.
(d) There is no difference.

Correct answer is (a)

Your score on this question is: 10.00

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



7.
In a C++ class, access to data members and function members are typically

(a) both public
(b) public and private, respectively
(c) private and public, respectively
(d) both private

Correct answer is (c)

Your score on this question is: 10.00

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



8.
The purpose of a constructor is to

(a) prevent memory leaks
(b) handle assignments between instances of the class
(c) initialize data members of a class properly after space has been allocated
(d) clean up memory when an instance goes out of scope

Correct answer is (c)

Your score on this question is: 10.00

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



9.

Consider the following class outline for a user-defined implementation of real numbers.

      class  RealNumber {
            ...
            private:
                    RealNumber(void) {}
      };

Which of the following is true about such an implementation?



(a) It will be impossible to place RealNumber objects into a container.
(b) Since the class defines a private constructor, it cannot define any public constructors.
(c) It exhibits good general defensive programming by using private constructors.
(d) All RealNumber objects will be read-only.

Correct answer is (a)

Your score on this question is: 10.00

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



10.
Which of the following statements properly describes the restriction in C++ regarding what a function can return?

(a) Neither functions nor function objects can be returned.
(b) Neither function pointers nor function objects can be returned.
(c) Function pointers cannot be returned, but function objects can be returned.
(d) Functions cannot be returned, but function objects can be returned.

Correct answer is (d)

Your score on this question is: 10.00

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



Go to top of assessment.

Total score: 100.00