MCQ Bank
A post-fix unary operator is implemented in C++ using member function with:
- A) 1 dummy char argument
- B) 1 dummy float argument
- C) 1 dummy int argument
- D) 1 dummy string argument
In C++, which of the following keywords works only with constructors?
- A) const
- B) virtual
- C) static
- D) explicit
Target class of a _______ function call is determined at run time.
- A) Instance
- B) Operator
- C) Non- Virtual
- D) Virtual
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=11
- B) oldValue= 11 , newValue=11
- C) oldValue= 11 , newValue=10
- D) oldValue= 10 , newValue=10
The C++ code “class circle : public shape” shows______________ relationship.
- A) Aggregation
- B) Inheritance
- C) Simple Association
- D) Composition
Which of the following is NOT casting operator in C++ standard?
- A) reinterpret_cast
- B) dynamic_cast
- C) var_cast
- D) static_cast
Suppose Person is a user defined class. In statement “Person * pPtr”, static type of pPtr is ____________.
- A) Person*
- B) Person
- C) pPtr
- D) Object
In case of public inheritance, protected members of base class will be _____________ in derived class.
- A) hidden
- B) private
- C) public
- D) protected
Which statement will be true for concrete class?
- A) None of given options.
- B) It cannot be inherited from an abstract class.
- C) It cannot be instantiated.
- D) It can be instantiated.
________________ represents “IS A” relationship.
- A) Aggregation
- B) Composition
- C) Simple Association
- D) Inheritance
Which of the following is/are casting operator(s) in C++?
- A) dynamic_cast
- B) const_cast
- C) All of the given options
- D) static_cast
<p>Consider the code below:</p> <p>class class1</p> <p>{</p> <p>private: 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>protected</p>
- B) <p>public</p>
- C) <p>private/hidden</p>
- D) <p>static</p>
If the user does not specify the type of inheritance then the default type of inheritance is ____________.
- A) Default
- B) Protected inheritance
- C) Public inheritance
- D) Private inheritance
<p>Consider the code below:</p> <p>class class1</p> <p>{</p> <p> private: int i;</p> <p>};</p> <p>class class2 : public class1</p> <p>{ };</p> <p>Then int member i of class1 is ______ in class2.</p>
- A) <p>public</p>
- B) <p>protected</p>
- C) <p>static</p>
- D) <p>private</p>
If you have three classes in a C++ program A, B, and C where class A inherits from class B, then class _____________ contains all the characteristics of class _________________.
- A) A, B
- B) A, C
- C) B, C
- D) B, A
What does the virtual keyword ensure when used in a base class function in C++?
- A) Static function resolution
- B) Early binding
- C) Dynamic binding
- D) Constructor overloading
<p>Consider the code below:</p> <p>class class1</p> <p>{</p> <p> private: void func1();</p> <p>};</p> <p>class class2 : public class1</p> <p>{ };</p> <p>Function func1 of class1 is ______ in class2.</p>
- A) <p>static</p>
- B) <p>protected</p>
- C) <p>private</p>
- D) <p>public</p>
In C++, dynamic binding and polymorphism will be achieved when member function will be ____.
- A) public
- B) virtual
- C) inline
- D) private
<p>Consider the code below:</p> <p>class class1</p> <p>{</p> <p>public: 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>private/hidden</p>
- C) <p>protected</p>
- D) <p>public</p>
<p>Consider the code below:</p> <p>class class1</p> <p>{</p> <p> private: int i;</p> <p>};</p> <p>class class2 : protected class1</p> <p>{ };</p> <p>Then int member i of class1 is ______ in class2.</p>
- A) <p>static</p>
- B) <p>protected</p>
- C) <p>public</p>
- D) <p>private</p>