Object Oriented Programming MCQ: OOP MCQ and Answers

Object-Oriented Programming MCQ. The answers are highlighted in each MCQ.


Object-Oriented Programming MCQ


1- What the function templates can accept ??

(A) Only one parameter

(B) Any type of parameters

(C) Only parameters if the basic type

(D) None of these


2- A mechanism that binds code and data together and keeps them secure from the outside world is called ??

(A) Protection

(B) Encapsulation

(C) Safeguard

(D) Abstraction


3- The #ifndef directive tests to see which of these ??

(A) a variable has been given a value 

(B) any objects of the class have been initiated

(C) a class has been defined

(D) a class has no variable definitions


4- The generic type in a template function

(A) cannot be T

(B) must be T 

(C) cannot be T for the functions you create

(D) can be T


5- Where the compiler looks for a matching function name when a child class function is called ??

(A) class of the object using the function name

(B) base class

(C) ancestor class

(D) all of the above


6- The operator << when overloaded in a class ??

(A) must be a non-member function

(B) must be a member function 

(C) cannot be overloaded

(D) Both (a) and (b)


7- When to provide a destructor in a class ??

(A) Class for which copy constructor is defined

(B) Class whose objects will be created dynamically

(C) In every class

(D) Class for which two or more than two objects will be created


8- Each time an object is destroyed then which function is called automatically?? 

(A) terminator

(B) destructor

(C) destroyer 

(D) constructor


9- To declare as a friend which of these is possible ??

(A) Class

(B) member function

(C) global function

(D) All of the above


10- A class is the same as “struct” except ??

(A) Can’t be used in the inheritance hierarchy

(B) There are no member functions

(C) It has this pointer

(D) All members are public


Object Oriented Programming MCQ


11- The original developer of C++ was ??

(A) Sir Richard Hadlee

(B) Bjarne Stroustrup

(C) Donald E.Knuth

(D) Melish and Clocksin


12- The step-by-step instructions for solving a problem are called ??

(A) a plan

(B) a sequential structure

(C) an algorithm

(D) a list


13- What type to be used in the instantiation of a class template follows ??

(A) the template definition

(B) the keyword class

(C) the keyword template

(D) The generic class name 


14- What will be the default mode of the file if we create a file by “ifstream” ??

(A) ios :: app

(B) ios :: in

(C) ios :: binary

(D) ios :: out


15- Which of these statements can characterize polymorphism ??

(A) Multiple interfaces and one method

(B) One interface and one method

(C) One interface and multiple methods

(D) All of the above


16- What is a virtual class ??

(A) Base class

(B) An abstract class

(C) A class with a virtual function

(D) None of these


17- Which of these operators can not be overloaded ??

(A) : : 

(B) ( )

(C) ++

(D) ~


18- Among these given declarations the illegal declaration is ??

(A) const *int p1;

(B) void *ptr

(C) char str = “hi”;

(D) char *str = “hi”;


19- Which of the following operator is not used with pointers ??

(A) &

(B) >>

(C) *

(D) ->


20- About operator overloading which statement is incorrect ??

(A) Overloaded operator must have at least one operand of its class type

(B) The overloaded operators follow the syntax rules of the original operator

(C) Only existing operators can be overloaded

(D) None of these




21- What it takes to overload a postfix increment operator by means of a member function ??

(A) Two arguments

(B) One argument

(C) No argument

(D) Three arguments


22- If x =9.7 then which among these will produce 10 as a result ??

(A) ceil(x)

(B) floor(x)

(C) abs(x)

(D) log(x)


23- What in these is not a property of a constructor ??

(A) They do not have a return type

(B) They can be virtual

(C) They should be declared in a public class

(D) They cannot be inherited


24- How do you separate a derived class name from its access specifier ??

(A) semicolon

(B) one space at least

(C) two colons 

(D) a dot


25- Suppose “C” is a class name then the friend function of this class cannot access??

(A) Data members of the derived class of C

(B) Private data members and member functions

(C) Protected data members and member functions

(D) Public data members and member functions


26- The members of every class by default are ??

(A) Default

(B) Private

(C) Public

(D) Protected


27- How C++ pass only the contents of the variable to the receiving function when you pass a variable ??

(A) by value

(B) locally

(C) by reference

(D) globally


28- Which of these is the best form of coupling ?? 

(A) tight

(B) loose

(C) complete 

(D) free


29- Ignoring inessential details and paying attention to the important properties is known as what ??

(A) summarizing

(B) polymorphism

(C) abstraction

(D) selectiveness


30- C++ does append to the end of the string literal constant ??

(A) an asterisk *

(B) a null character

(C) space

(D) a number sign


   Read More

Leave a Comment

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

error: Content is protected !!