MCQ Bank
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>
If a class is inherited using private inheritance, what happens to public members of the base class?
- A) Become protected
- B) Become private
- C) Become inaccessible
- D) Remain public
Which of the following access specifier ensures that base class member is accessible in derived class of this base class and NOT outside of this class?
- A) protected
- B) Static
- C) public
- D) private
Which class has at least one pure virtual function?
- A) Abstract class
- B) Child class
- C) Template class
- D) Concrete class
In case of protected inheritance, public members of base class will be _____________ in derived class.
- A) protected
- B) hidden
- C) private
- D) public
In C++, a function is made pure virtual by adding ____________ at the end of its declaration.
- A) = -1
- B) = 0
- C) = 2
- D) = 1
___________ binding means that target function for a call is selected at run time.
- A) Static
- B) Constant
- C) Automatic
- D) Dynamic
What is function overriding in C++?
- A) Calling a function multiple times
- B) Redefining a base class function in a derived class
- C) Using global functions inside a class
- D) Defining multiple functions with the same name in one class
In which of the following way(s), we can inherit a class from another class in C++?
- A) Protected
- B) Private
- C) Public
- D) All of the given options
Which casting in C++ involves a runtime check and returns a null pointer if the conversion is not possible?
- A) Static cast
- B) Const cast
- C) Reinterpret cast
- D) Dynamic cast
Which of the following is not type of inheritance in C++?
- A) private
- B) public
- C) restricted
- D) protected