CS201p Quiz Lab 13 & 14 Spring 2023

CS201p Quiz Lab 13 & 14 Spring 2023


Question #1:

We cannot declare a function as a friend of _______class.

Options:

A) double

B) stream

C) Istream

D) ostream only

Correct Option: D) ostream only


Question #2:

Variables defined in the main function are____ to the function main().

Options:

A) Local

B) Static

C) Private

D) Global

Correct Option: A) Local


Question #3:

'T' is ___ data type in "template <class T>".

Options:

A) Specific

B) Double

C) Float

D) Generic

Correct Option: D) Generic


Question #4:

Which of the following is not an advantage of templates?

Options:

A) Templates are not type-safe.

B) Helps in compiler optimizations.

C) Provide code reusability.

D) Easy to understand.

Correct Option: A) Templates are not type-safe.


Question #5:

In function calling, by which method you can call the copy constructor?

Options:

A) Pointer

B) Reference

C) Value

D) Call by value

Correct Option: D) Call by value


Question #6:

Which of the following statement is not true about overloading stream extraction operator (>>)?

Options:

A) It can be a member operator.

B) First parameter is of type 'istream &'.

C) Second parameter is passed by reference.

D) Returns an object of type 'istream &'.

Correct Option: A) It can be a member operator.


Question #7:

Which statement about manipulator is not true?

Options:

A) The left-hand side is ostream object.

B) Stream insertion operator is on the right-hand side.

C) It automatically gets that object as a parameter passed in to the function.

D) They return a reference to the insertion operator.

Correct Option: D) They return a reference to the insertion operator.


Question #8:

Which of the following is the correct format of a template function?

Options:

A) template [class T]

B) template class <T>

C) template class [T]

D) template<class T>

Correct Option: D) template<class T>


Question #9:

We can always specify a member initializer to call a _______ constructor.

Options:

A) Default

B) Parameterized

C) Non-parameterized

D) Copy

Correct Option: B) Parameterized


Question #10:

Classes defined within other classes are ______.

Options:

A) Parent Classes

B) Outer Classes

C) Nested Classes

D) Child Classes

Correct Option: C) Nested Classes