MCQ Bank
virtual void print(); is an example of_________________.
- A) virtual function
- B) template function
- C) simple function
- D) pure virtual function
In dynamic binding, the function call is resolved:
- A) During compilation
- B) Before compilation
- C) During execution
- D) At linking time
Static binding means:
- A) Function selected at compile time
- B) Function selected at run time
- C) Function selected randomly
- D) Function selected randomly
Virtual functions can be used in ________ ways.
- A) 0
- B) 8
- C) 2
- D) 6
A class with pure virtual function is called ________ class.
- A) normal
- B) concrete
- C) solid
- D) abstract
virtual void print(); is an example of_________________.
- A) virtual function
- B) pure virtual function
- C) simple function
- D) template function
Static binding means:
- A) Function selected at compile time
- B) Function selected randomly
- C) Function selected randomly
- D) Function selected at run time
Virtual functions can be used in ________ ways.
- A) 6
- B) 8
- C) 2
- D) 0
A class with pure virtual function is called ________ class.
- A) concrete
- B) abstract
- C) solid
- D) normal
When is a class template instantiated?
- A) At runtime
- B) At compile time
- C) When linked
- D) When declared
Which of the following is the correct syntax for a function template in C++?
- A) func<class T>(T a);
- B) template<type T> func(T a);
- C) template<class T> void func(T a);
- D) template void func<class T>(T a);
What is the purpose of a generic algorithm in C++?
- A) To create run-time polymorphism
- B) To make algorithms independent of data structures
- C) To handle integer data only
- D) To avoid the use of pointers
In a function template template<typename T>, what does T represent?
- A) Function return value
- B) Built-in type
- C) Non-type parameter
- D) Type parameter
Function templates are preferred over overloading when
- A) They have different names
- B) Functions differ only by parameter types
- C) They have different numbers of arguments
- D) They return different types
The partial specialization pattern T* says that this specialization is to be used for every _______.
- A) Meta type
- B) Virtual type
- C) Pointer type
- D) Data type
The relationship between container and contained objects is called ___________.
- A) Association
- B) Aggregation
- C) Composition
- D) Inheritance
Which of the following best defines static data members of a class?
- A) Data member with global scope
- B) Data member which is common to all the objects of a class
- C) Data member which is common to all the classes in a program
- D) Data member which is allocated for each object separately
Which statement is true about life of a static data member?
- A) They remains in memory even if all objects are destroyed.
- B) Static data members are destroyed when single object of a class is destroyed.
- C) Static data member exists only within the scope of the class constructor.
- D) Static members are destroyed dynamically.
Which of the following is correct feature that is used to make basic operators like +, - , * and / etc. to work with user defined types?
- A) operator overloading
- B) inheritance
- C) type loading
- D) abstraction
What is the purpose of new operator?
- A) Used as return type when an object is created
- B) Used to declare any new thing in a program
- C) Allocates memory for an object or array and returns a particular pointer
- D) Allocates memory for an object or array