This set of Object Oriented Programming MCQs focuses on “Object Use”.
a) To create instance of a function
b) To create instance of a program
c) To create instance of class
d) To create instance of structures
Explanation: The objects are used to create instance of a class. Objects can represent a class in an independent form. The basic blueprint, that contains the information of the type of data that can be stored in an object, is given by the class.
2. Which among the following is not a property of an object?
Explanation: The names are not property of an object. The identity can be in any form like address or name of object but name can’t be termed as only identity of an object. The objects contain attributes that define what type of data an object can store.
3. What is function object?
a) An object with a single function
b) An object with only functions
c) An object with more than one function
d) An object with no functions
Explanation: A function object is the object with single function. In C++ a function object can be like operator() function. This acts more like a function rather than an object.
4. Immutable object are used ______________________
a) To set up as a fixed state
b) To set up variable object
c) To set up an object of abstract class
d) To set up an object of derived class
Explanation: An immutable object can be created for an object which have to be fixed with values. The object data will not be changed throughout the program. This can be useful to eliminate the unintentional changes in the data of object.
5. Which object can be used to contain other objects?
a) First class object
b) Derived class object
c) Container object
d) Enclosure object
Explanation: A container object can be used to contain other objects. Container object is an ADT. Its object are collection of other objects. Some specific rules apply to these type of objects.
a) To create new classes
b) To create new function
c) To create new data members
d) To create new objects
Explanation: The factory object is an object that can be used to create other objects. If it is seen formally, it behaves like a method that will return object on its use. The object returned is assumed to be a new object.
7. What are singleton objects?
a) The only two objects of a class throughout the program
b) The only object of a class throughout the program
c) The objects that are alive throughout the program
d) The objects that are created and then deleted without use
Explanation: If a class has only one object created and that is the only object of the class. Then the object is known as singleton object. But only if that object is the only object of the class and no other object is created for that class.
8. Object cout and cin _________________
a) Can be used directly with << and >> symbols respectively
b) Can be used directly with >> and << symbols respectively
c) Must be used as a function which accepts 2 arguments
d) Must be used as a function which accepts 3 arguments
Explanation: The cin and cout objects can be used directly with the >> and << operators respectively. The objects are of iostream class. Class iostream is an inbuilt class.
9. Objects type ____________________
a) Can be changed in runtime
b) Can’t be changed in runtime
c) Can be changed in compile time
d) May or may not get changed
Explanation: The object types are always fixed. Once the object is created of a specific type then it can’t be changed. Neither at runtime nor at compile time.
10. An object can be used to represent _________________
a) A real world entity
b) A real function
c) Some real data only
d) Some function only
Explanation: The objects are actually meant to represent an entity. The classes are real world object’s blueprint. The classes then are used to create an entity representation.
11. Objects can be used _____________________
a) To access any member of a class
b) To access only public members of a class
c) To access only protected members of a class
d) To access only private members of a class
Explanation: The objects are created for a specific class. Then the objects can be used to access the public members of a class. The members can be the data members or the member functions of the class.
a) Defining a member function
b) Accessing data members
c) Creating instance of a class
d) Using class members
Explanation: The objects can’t be used to define any member function. Member functions must be defined by the class only. Objects can only access the members and use them.
13. Which object can be used to access the standard input?
Explanation: Object cin can be used to take input from the standard input. It is used in C++. In java we can use System.in for the standard input stream. The syntax changes from language to language.
14. A single object can be used __________________
a) As only two class types at a time
b) As only three class types at a time
c) As only one class type at a time
d) As of as many class types as required
Explanation: The object can be of only one type. The type of an object can’t be changed. Object type is mandatory to be of one class type to ensure the type and number of data members it have.
15. If same object name is given to different objects of different class then _____________
a) Its compile time error
b) Its runtime error
c) It’s not an error
d) Program suns smooth
Explanation: It is a compile time error as the compiler doesn’t allow same name objects to be declared more than once. Compiler produces multiple declaration error. Every object must have a different name.
Sanfoundry Global Education & Learning Series – Object Oriented Programming (OOPs).
To practice MCQs on all areas of Object Oriented Programming, here is complete set of 1000+ Multiple Choice Questions and Answers.