This section contains more frequently asked Programming In C++ Basics MCQs in the various University Level and Competitive Examinations.
1. A virtual class is the same as
- an abstract class
- a class with a virtual function
- a base class
- none of the above.
D. none of the above.
2. Identify the operator that is NOT used with pointers
- ->
- &
- *
- >>
D. >>
3. Consider the following statements char *ptr; ptr = “hello”; cout << *ptr; What will be printed?
- first letter
- entire string
- it is a syntax error
- last letter
A. first letter
4. In which case is it mandatory to provide a destructor in a class?
- Almost in every class
- Class for which two or more than two objects will be created
- Class for which copy constructor is defined
- Class whose objects will be created dynamically
D. Class whose objects will be created dynamically
5. The members of a class, by default, are
- public
- protected
- private
- mandatory to specify
C. private
6. Given a class named Book, which of the following is not a valid constructor?
- Book ( ) { }
- Book ( Book b) { }
- Book ( Book &b) { }
- Book (char* author, char* title) { }
B. Book ( Book b) { }
7. Which of the statements is true in a protected derivation of a derived class from a base class?
- Private members of the base class become protected members of the derived class
- Protected members of the base class become public members of the derived class
- Public members of the base class become protected members of the derived class
- Protected derivation does not affect private and protected members of the
C. Public members of the base class become protected members of the derived class
8. Which of the following statements is NOT valid about operator overloading?
- Only existing operators can be overloaded.
- Overloaded operator must have at least one operand of its class type.
- The overloaded operators follow the syntax rules of the original operator.
- none of the above.
D. none of the above.
9. Exception handling is targeted at
- Run-time error
- Compile time error
- Logical error
- All of the above.
A. Run-time error
10. A pointer to the base class can hold address of
- only base class object
- only derived class object
- base class object as well as derived class object
- None of the above
C. base class object as well as derived class object