MCQ Bank
<p>Consider the code below:</p> <p>class class1</p> <p>{</p> <p>protected: void func1();</p> <p>};</p> <p>class class2 : private class1</p> <p>{ };</p> <p>Function func1 of class1 is ______ in class2.</p>
- A) <p>protected</p>
- B) <p>static</p>
- C) <p>private/hidden</p>
- D) <p>public</p>
<p>Consider the code below:</p> <p>class class1</p> <p>{</p> <p>private: void func1();</p> <p>};</p> <p>class class2 : protected class1</p> <p>{ };</p> <p>Function func1 of class1 is ______ in class2.</p>
- A) <p>private/hidden</p>
- B) <p>public</p>
- C) <p>static</p>
- D) <p>protected</p>
Which of the following is an example of unary operator?
- A) Equality Operator ( = =)
- B) Increment Operator ( ++ )
- C) Division Operator ( / )
- D) Inequality Operator ( != )
Consider the following C++ code fragment written for a class Student: Student sobj1; Student sobj2(sobj1); Upon execution of second statement, which constructor of Student class will be called?
- A) Copy constructor of Student class
- B) Both Default and Copy constructor of Student class
- C) Default constructor of Student class
- D) Parameterized constructor of Student class
Compiler generated copy constructor performs __________.
- A) Shallow copy
- B) Both Shallow and Deep copy
- C) Deep copy
- D) Bitwise copy
Which of the following is pure virtual function?
- A) virtual void print() = 0;
- B) void print();
- C) virtual void print();
- D) void print() = 0;
Suppose you have following C++ statements: int oldValue=10; int newValue = oldValue ++; What will be the value of oldValue and newValue after executing above statements?
- A) oldValue= 10 , newValue=10
- B) oldValue= 11 , newValue=10
- C) oldValue= 10 , newValue=11
- D) oldValue= 11 , newValue=11
A post-fix unary operator is implemented in C++ using non-member function with __________ argument(s).
- A) Three
- B) One
- C) Two
- D) Zero
<p>Consider the code below:</p> <p>class class1</p> <p>{</p> <p>protected: int i;</p> <p>};</p> <p>class class2 : private class1</p> <p>{ };</p> <p>Then int member i of class1 is ______ in class2.</p>
- A) <p>static</p>
- B) <p>public</p>
- C) <p>private/hidden</p>
- D) <p>protected</p>
Which of the following is known as Dereference operator in C++?
- A) ::
- B) *
- C) +
- D) &
In case of template specialization, if compiler cannot find required complete specialization then it searches for some _____________________.
- A) General Template
- B) Complete Specialization
- C) None of the given options
- D) Partial Specialization
In resolution order of function templates, compiler searches for _____________ in the end.
- A) generic template
- B) complete specialization
- C) partial specialization
- D) ordinary function
Which of the following is correct code to instantiate the object of given template Vector class for int type?
template <class T>
class Vector
{
};
- A) Vector <int> obj;
- B) Vector int obj;
- C) Vector obj<>int;
- D) Vector obj <int>;
Which of the following represents partial specialization?
- A) template< int , char >
- B) template< class T, class U, int >
- C) template< typename T, class W >
- D) template< class T, type T>
Polymorphism always works with ___________.
- A) pointer to class objects
- B) constant objects
- C) static objects
- D) actual objects
When we specialize a function template, it is called _____________________.
- A) function overloading
- B) function overriding
- C) function template overloading
- D) function template overriding
When we want to have exactly identical operations on different data types, ______________ are used.
- A) Function Overloading
- B) None of the given options
- C) Function Overriding
- D) Function Templates
Which of the following is correct way to define a template class X?
- A) typename <class T > class X { };
- B) template< typename T > class X { };
- C) template class X { };
- D) class< typename T > class X { };
Which of the following may inherit from an ordinary class?
- A) All of the given options
- B) Complete specialization
- C) Partial specialization
- D) Class template
Which of the following can be passed as type arguments to templates?
- A) None of the given options
- B) Both Primitive types and User-defined types
- C) User-defined types
- D) Primitive types