250+ TOP MCQs on OOPs Concept and Answers Quiz Exam

C++ Programming Objective Questions & Answers on “OOPs Concept”.

1. Which operator is overloaded for a cout object?
a) >>
b) <<
c) <
d) >

Answer: b
Clarification: cout in C++ uses << operator to print anything so << operator is overloaded for a cout object.

2. Which of the following cannot be used with the virtual keyword?
a) Class
b) Member functions
c) Constructors
d) Destructors

Answer: c
Clarification: Virtual keyword cannot be used with constructors as constructors are defined to initialized an object of particular class hence no other class needs constructor of other class.

3. Which concept is used to implement late binding?
a) Virtual functions
b) Operator functions
c) Constant functions
d) Static functions

Answer: a
Clarification: Virtual functions are used to implement the concept of late binding i.e. binding actual functions to their calls.

4. Which of the following is correct?
a) C++ allows static type checking
b) C++ allows dynamic type checking.
c) C++ allows static member function to be of type const.
d) C++ allows both static and dynamic type checking

Answer: d
Clarification: C++ allows both static and dynamic type checking i.e. types are checked by the compiler.

5. Which of the following supports the concept that reusability is a desirable feature of a language?
a) It reduces the testing time
b) It reduces maintenance cost
c) It decreases the compilation time
d) It reduced both testing and maintenance time

Answer: d
Clarification: As we will be using the existing code therefore we don’t need to check the code again and again so testing and maintenance time decreases but the compiler time may increase or remains same because though we are reusing the code but every part needs to be compiled and extra include statement needs to be executed therefore compilation time may remain same or increases.

6. Which of the following is a static polymorphism mechanism?
a) Function overloading
b) Operator overloading
c) Templates
d) All of the mentioned

Answer: d
Clarification: All the options mentioned above uses static polymorphism mechanism. As the conflicts in all these types of functions are resolved during compile-time.

7. Which of the following is true?
I) All operators in C++ can be overloaded.
II) The basic meaning of an operator can be changed.
a) I only
b) II only
c) Both I and II
d) Neither I nor II

Answer: d
Clarification: Both statements are false because all the operators of C++ cannot be overloaded and the basic meaning of an operator cannot be changed, we can only give new meaning to an operator.

8. Which of the following is not a type of inheritance?
a) Multiple
b) Multilevel
c) Distributive
d) Hierarchical

Answer: c
Clarification: Distributive is not a type of inheritance whereas others are a type of inheritance having their own meaning.

9. What happens if a class does not have a name?
a) It will not have a constructor
b) It will not have a destructor
c) It is not allowed
d) It will neither have a constructor or destructor

Answer: b
Clarification: A class without a name will not have a destructor. The object is made so constructor is required but the destructor is not. Check the code below:

#include 
using namespace std;
class
{
    public:
	void func()
        {
		cout<<"Hello world";
	}
}a;
int main(int argc, char const *argv[])
{
	a.func();
	return 0;
}

10. Which of the following statement is true?
I) In Procedural programming languages, all function calls are resolved at compile-time
II) In Object Oriented programming languages, all function calls are resolved at compile-time
a) I only
b) II only
c) Both I and II
d) Neither I nor II

Answer: a
Clarification: In Procedural programming like C we don’t have the concept of polymorphism, therefore, all the function calls are resolved at the compile-time but in case of OOP languages sue to polymorphism concept all function calls are not resolved at compile-time.

11. Which members are inherited but are not accessible in any case?
a) Private
b) Public
c) Protected
d) Both private and protected

Answer: a
Clarification: Private members of a class are inherited to the child class but are not accessible from the child class.

12. Which of the following is correct?
a) Friend functions can access public members of a class
b) Friend functions can access protected members of a class
c) Friend functions can access private members of a class
d) All of the mentioned

Answer: d
Clarification: Friend functions can access any member of a class without caring about the type of member i.e. without caring whether it is private, protected or public.

13. Which of the following is correct in C++?
a) Classes cannot have protected data members
b) Structures can have member functions
c) Class members are public by default
d) Structure members are private by default

Answer: b
Clarification: Though C does not allows member functions in structures but C++ allows structures to have member functions. Members of structures are public by default and those of classes are private by default. Classes can have protected data members.

14. Which of the following is used to make an abstract class?
a) By using virtual keyword in front of a class declaration
b) By using an abstract keyword in front of a class declaration
c) By declaring a virtual function in a class
d) By declaring a pure virtual function in a class

Answer: d
Clarification: Abstract class should have at least one pure virtual function. Therefore to declare an abstract class one should declare a pure virtual function in a class.

15. Which of the following is correct?
a) A class is an instance of its objects
b) An object is an instance of its class
c) A class is an instance of the data type that the class have
d) An object is an instance of the data type of the class

Answer: b
Clarification: An object is an instance of a class i.e. an object represents a class i.e. what class has(data members) and what it can do(member functions).

Leave a Reply

Your email address will not be published. Required fields are marked *