111
80.8k

200+ Object Oriented Programming with C++ (OOP in C++) Solved MCQs

These multiple-choice questions (MCQs) are designed to enhance your knowledge and understanding in the following areas: Bachelor of Computer Applications (BCA) , Programming Languages .

101.

A private member function can be called by another function that is a member of a class is called

A. Friend function
B. Nesting of member function
C. Inline function
D. Static function
Answer» B. Nesting of member function
102.

The function that is a bridge between two classes

A. Friend function
B. Nesting of member function
C. Inline function
D. Static function
Answer» A. Friend function
103.

The break statement causes an exit

A. from the innermost loop only.
B. only from the innermost switch.
C. from all loops & switches.
D. from the innermost loop or switch.
Answer» C. from all loops & switches.
104.

The arrays of variable that are of the type class

A. Array of object
B. pointer
C. Object
D. Structure
Answer» A. Array of object
105.

Which of the following is not a type of constructor?

A. Copy constructor
B. Friend constructor
C. Default constructor
D. Parameterized construct
Answer» B. Friend constructor
106.

Which of the following statements is incorrect?

A. Friend keyword can be used in the class to allow access to another class.
B. Friend keyword can be used for a function in the public section of a class.
C. Friend keyword can be used for a function in the private section of a class.
D. Friend keyword can be used on main().
Answer» D. Friend keyword can be used on main().
107.

Which of the following statement is correct regarding destructor of base class?

A. Destructor of base class should always be static.
B. Destructor of base class should always be virtual.
C. Destructor of base class should not be virtual.
D. Destructor of base class should always be private.
Answer» B. Destructor of base class should always be virtual.
108.

How can we make a class abstract?

A. By making all member functions constant.
B. By making at least one member function as pure virtual function.
C. By declaring it abstract using the static keyword.
D. By declaring it abstract using the virtual keyword.
Answer» B. By making at least one member function as pure virtual function.
109.

Which of the following statements is correct when a class is inherited publicly?

A. Public members of the base class become protected members of derived class.
B. Public members of the base class become private members of derived class.
C. Private members of the base class become protected members of derived class.
D. Public members of the base class become public members of derived class.
Answer» D. Public members of the base class become public members of derived class.
110.

Which of the following access specifies is used in a class definition by default?

A. Protected
B. Public
C. Private
D. Friend
Answer» C. Private
111.

Which of the following statement is correct with respect to the use of friend keyword inside a class?

A. A private data member can be declared as a friend.
B. A class may be declared as a friend.
C. An object may be declared as a friend.
D. We can use friend keyword as a class name.
Answer» B. A class may be declared as a friend.
112.

Which of the following keywords is used to control access to a class member?

A. Default
B. Break
C. Protected
D. Asm
Answer» C. Protected
113.

Which of the following type of data member can be shared by all instances of its class?

A. Public
B. Inherited
C. Static
D. Friend
Answer» C. Static
114.

Constructor is executed when _____.

A. an object is created
B. an object is used
C. a class is declared
D. an object goes out of scope.
Answer» A. an object is created
115.

Which of the following also known as an instance of a class?

A. Friend Functions
B. Object
C. Member Functions
D. Member Variables
Answer» B. Object
116.

How many objects can be created from an abstract class?

A. Zero
B. One
C. Two
D. As many as we want
Answer» A. Zero
117.

Which of the following statements is correct?

A. Data items in a class must be private.
B. Both data and functions can be either private or public.
C. Member functions of a class must be private.
D. Constructor of a class cannot be private.
Answer» B. Both data and functions can be either private or public.
118.

Which of the following can be overloaded?

A. Object
B. Functions
C. Operators
D. Both B and C
Answer» D. Both B and C
119.

Which of the following is the only technical difference between structures and classes in C++?

A. Member function and data are by default protected in structures but private in classes.
B. Member function and data are by default private in structures but public in classes.
C. Member function and data are by default public in structures but private in classes.
D. Member function and data are by default public in structures but protected in classes.
Answer» C. Member function and data are by default public in structures but private in classes.
120.

Which of the following statements are correct for a static member function? 1. It can access only other static members of its class. 2. It can be called using the class name, instead of objects.

A. Only 1 is correct.
B. Only 2 is correct.
C. Both 1 and 2 are correct.
D. Both 1 and 2 are incorrect.
Answer» C. Both 1 and 2 are correct.
121.

Which of the following means "The use of an object of one class in definition of another class"?

A. Encapsulation
B. Inheritance
C. Composition
D. Abstraction
Answer» C. Composition
122.

Which of the following statements is correct when a class is inherited publicly?

A. Public members of the base class become protected members of derived class.
B. Public members of the base class become private members of derived class.
C. Private members of the base class become protected members of derived class.
D. Public members of the base class become public members of derived class
Answer» D. Public members of the base class become public members of derived class
123.

Which of the following statements is correct about the constructors and destructors?

A. Destructors can take arguments but constructors cannot.
B. Constructors can take arguments but destructors cannot.
C. Destructors can be overloaded but constructors cannot be overloaded.
D. Constructors and destructors can both return a value.
Answer» B. Constructors can take arguments but destructors cannot.
124.

Which of the following statement is correct?

A. C++ enables to define functions that take constants as an argument.
B. We cannot change the argument of the function that that are declared as constant.
C. Both A and B.
D. We cannot use the constant while defining the function.
Answer» C. Both A and B.
125.

Which of the following statement is correct?

A. Two functions having same number of argument, order and type of argument can be overloaded if both functions do not have any default argument.
B. Overloaded function must have default arguments.
C. Overloaded function must have default arguments starting from the left of argument list.
D. A function can be overloaded more than once.
Answer» D. A function can be overloaded more than once.
126.

Which of the following statement will be correct if the function has three arguments passed to it?

A. The trailing argument will be the default argument.
B. The first argument will be the default argument.
C. The middle argument will be the default argument.
D. All the argument will be the default argument.
Answer» A. The trailing argument will be the default argument.
127.

Which of the following statement is incorrect?

A. Default arguments can be provided for pointers to functions.
B. A function can have all its arguments as default.
C. Default argument cannot be provided for pointers to functions.
D. A default argument cannot be redefined in later declaration.
Answer» C. Default argument cannot be provided for pointers to functions.
128.

Which of the following statement is correct?

A. Constructors can have default parameters.
B. Constructors cannot have default parameters.
C. Constructors cannot have more than one default parameter.
D. Constructors can have at most five default parameters.
Answer» A. Constructors can have default parameters.
129.

Which of the following function / type of function cannot be overloaded?

A. Member function
B. Static function
C. Virtual function
D. Both B and C
Answer» C. Virtual function
130.

Which of the following statement is incorrect?

A. The default value for an argument can be a global constant.
B. The default arguments are given in the function prototype.
C. Compiler uses the prototype information to build a call, not the function definition.
D. The default arguments are given in the function prototype and should be repeated in the function definition.
Answer» D. The default arguments are given in the function prototype and should be repeated in the function definition.
131.

Where the default value of parameter have to be specified?

A. Function call
B. Function definition
C. Function prototype
D. Both B or C
Answer» C. Function prototype
132.

Which of the following statement is correct?

A. The default value for an argument cannot be function call.
B. C++ allows the redefinition of a default parameter.
C. Both A and B.
D. C++ does not allow the redefinition of a default parameter.
Answer» D. C++ does not allow the redefinition of a default parameter.
133.

Which of the following statement is correct?

A. Only one parameter of a function can be a default parameter.
B. Minimum one parameter of a function must be a default parameter.
C. All the parameters of a function can be default parameters.
D. No parameter of a function can be default.
Answer» C. All the parameters of a function can be default parameters.
134.

Which of the following function / types of function cannot have default parameters?

A. Member function of class
B. main()
C. Member function of structure
D. Both B and C
Answer» B. main()
135.

A constructor that accepts __________ parameters is called the default constructor.

A. one
B. two
C. no
D. three
Answer» C. no
136.

What happens when a class with parameterized constructors and having no default constructor is used in a program and we create an object that needs a zero‐argument constructor?

A. Compile‐time error.
B. Preprocessing error.
C. Runtime error.
D. Runtime exception.
Answer» A. Compile‐time error.
137.

Destructor has the same name as the constructor and it is preceded by ______ .

A. !
B. ?
C. ~
D. $
Answer» C. ~
138.

For automatic objects, constructors and destructors are called each time the objects

A. enter and leave scope
B. inherit parent class
C. are constructed
D. are destroyed
Answer» A. enter and leave scope
139.

Which constructor function is designed to copy objects of the same class type?

A. Create constructor
B. Object constructor
C. Dynamic constructor
D. Copy constructor
Answer» D. Copy constructor
140.

Which of the following statement is correct?

A. Constructor has the same name as that of the class.
B. Destructor has the same name as that of the class with a tilde symbol at the beginning.
C. Both A and B.
D. Destructor has the same name as the first member function of the class.
Answer» C. Both A and B.
141.

When are the Global objects destroyed?

A. When the control comes out of the block in which they are being used.
B. When the program terminates.
C. When the control comes out of the function in which they are being used.
D. As soon as local objects die.
Answer» B. When the program terminates.
142.

Copy constructor must receive its arguments by __________ .

A. either pass‐by‐value or pass‐by‐reference
B. only pass‐by‐value
C. only pass‐by‐reference
D. only pass by address
Answer» C. only pass‐by‐reference
143.

A function with the same name as the class, but preceded with a tilde character (~) is called __________ of that class.

A. constructor
B. destructor
C. function
D. object
Answer» B. destructor
144.

Which of the following gets called when an object goes out of scope?

A. constructor
B. destructor
C. main
D. virtual function
Answer» B. destructor
145.

_________ used to make a copy of one class object from another class object of the same class type.

A. constructor
B. copy constructor
C. destructor
D. default constructor
Answer» B. copy constructor
146.

Constructors __________ to allow different approaches of object construction.

A. cannot overloaded
B. can be overloaded
C. can be called
D. can be nested
Answer» B. can be overloaded
147.

Which of the following cannot be declared as virtual?

A. Constructor
B. Destructor
C. Data Members
D. Both A and C
Answer» A. Constructor
148.

If the copy constructor receives its arguments by value, the copy constructor would

A. call one‐argument constructor of the class
B. work without any problem
C. call itself recursively
D. call zero‐argument constructor
Answer» C. call itself recursively
149.

Which of the following are NOT provided by the compiler by default?

A. Zero‐argument Constructor
B. Destructor
C. Copy Constructor
D. Copy Destructor
Answer» D. Copy Destructor
150.

It is a __________ error to pass arguments to a destructor.

A. logical
B. virtual
C. syntax
D. linker
Answer» C. syntax

Done Studing? Take A Test.

Great job completing your study session! Now it's time to put your knowledge to the test. Challenge yourself, see how much you've learned, and identify areas for improvement. Don’t worry, this is all part of the journey to mastery. Ready for the next step? Take a quiz to solidify what you've just studied.