Object Oriented Programming using C++ Questions and Answers – Object Use

«
»

This set of Object Oriented Programming using C++ MCQs focuses on “Object Use”.

1. Which among the following is the main use of object?
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
View Answer

Answer: c
Explanation: The objects are used to create an 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.
advertisement

2. Which among the following is not a property of an object?
a) Identity
b) Properties
c) Attributes
d) Names
View Answer

Answer: d
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
View Answer

Answer: a
Explanation: A function object is an object with single function. In C++ a function object can be like operator() function. This acts more like a function rather than an object.
advertisement
advertisement

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
View Answer

Answer: a
Explanation: An immutable object can be created for an object which has 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
View Answer

Answer: c
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 types of objects.
advertisement

6. A factory object is used ______________________
a) To create new classes
b) To create new function
c) To create new data members
d) To create new objects
View Answer

Answer:d
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
View Answer

Answer: b
Explanation: If a class has only one object created and that is the only object of the class. Then the object is known as the singleton object. But only if that object is the only object of the class and no other object is created for that class.
advertisement

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
View Answer

Answer: a
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
View Answer

Answer: b
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.
advertisement

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
View Answer

Answer: a
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
View Answer

Answer: b
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.

12. Which among the following is not a use of object?
a) Defining a member function
b) Accessing data members
c) Creating instance of a class
d) Using class members
View Answer

Answer: a
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?
a) System.inner
b) cin
c) System.stdin
d) console.input
View Answer

Answer: b
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
View Answer

Answer: c
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
View Answer

Answer: a
Explanation: It is a compile time error as the compiler doesn’t allow the same name objects to be declared more than once. Compiler produces multiple declaration errors. 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 using C++, here is complete set of 1000+ Multiple Choice Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter