⚙️ C++ Programming MCQs and Exam Questions

Practice 184 approved ⚙️ C++ Programming MCQs and exam questions from the 💻 Programming subject.

184 solved MCQs

Which of the following problem causes an exception?Answer: A run-time error. Which one of the following options is correct about the statement given below? The compiler checks the type of reference in the object and not the type of object.Answer: Polymorphism Which of the following is the correct way of declaring a function as constant?Answer: int ShowData(void) const { /* statements */ } Which of the following concepts is used to implement late binding?Answer: Virtual function Which of the following concepts is used to implement late binding?Answer: Virtual function Which of the following statement is correct?Answer: Both A and B. Which of the following factors supports the statement that reusability is a desirable feature of a language?Answer: Both A and B. Which of the following ways are legal to access a class data member using this pointer?Answer: this->x Which of the following is a mechanism of static polymorphism?Answer: All of the above Which of the following is correct about the statements given below? 1. All operators can be overloaded in C++. 2. We can change the basic meaning of an operator in C++.Answer: Both I and II are false. What happens if the base and derived class contains definition of a function with same prototype?Answer: Base class object will call base class function and derived class object will call derived class function. Which of the following are available only in the class hierarchy chain?Answer: Protected data members Which of the following is not a type of inheritance?Answer: Distributive Which of the following operators cannot be overloaded?Answer: ?: In which of the following a virtual call is resolved at the time of compilation?Answer: Both A and B. Which of the following statements regarding inline functions is correct?Answer: Both A and C. Which one of the following is the correct way to declare a pure virtual function?Answer: virtual void Display(void) = 0; Which of the following header file includes definition of cin and cout?Answer: iostream.h Which of the following keyword is used to overload an operator?Answer: operator What will happen if a class is not having any name?Answer: Both A and B. Which inheritance type is used in the class given below? class A : public X, public Y {}Answer: Multiple inheritance Which one of the following is correct about the statements given below? 1. All function calls are resolved at compile-time in Procedure Oriented Programming. 2. All function calls are resolved at compile-time in OOPS.Answer: Only I is correct. Which of the following is an invalid visibility label while inheriting a class?Answer: friend Which one of the following options is correct?Answer: All of the above. Which of the following statements is correct in C++?Answer: Structures can have functions as members. Which of the following is used to make an abstract class?Answer: Making at least one member function as pure virtual function. Which of the following access specifier is used as a default in a class definition?Answer: private What is correct about the static data member of a class?Answer: Both A and B. Which of the following provides a reuse mechanism?Answer: Inheritance Which of the following statement is correct?Answer: Object is an instance of a class.