Object Oriented Programming MCQs

Page No. 30

It is necessary to return the object if it was passed by reference to a function.


aYes, since the object must be same in caller function


bYes, since the caller function needs to reflect the changes


cNo, the changes are made automatically


dNo, the changes are made explicitly



What will be the output of the following code?


a inside constructor something destroying 2this is i in main destroying 1


binside constructor something this is i in main destroying 1


cinside constructor something destroying 2this is i in main


dsomething destroying 2this is i in main destroying 1



How many objects can be returned at once?


aOnly 1


bOnly 2


cOnly 16


dAs many as required


View Answer Only 1

How to overcome the problem arising due to destruction of temporary object?


aOverloading insertion operator


bOverriding functions can be used


cOverloading parenthesis or returning object


dOverloading assignment operator and defining copy constructor



Is the destruction of temporary object safe (while returning object)?


a Yes, the resources get free to use


bYes, other objects can use the memory space


cNo, unexpected side effects may occur


dNo, always gives rise to exceptions



When an object is returned by a function, a _______________ is automatically created to hold the return value.


aTemporary object


b Virtual object


c New object


d Data member


View Answer Temporary object

Constructor function is not called when an object is passed to a function, will its destructor be called when its copy is destroyed?


aYes, depending on code


bYes, must be called


cNo, since no constructor was called


dNo, since same object gets used


View Answer Yes, must be called

If an object is passed by reference, the changes made in the function ___________


aAre reflected to the main object of caller function too


bAre reflected only in local scope of the called function


c Are reflected to the copy of the object that is made during pass


dAre reflected to caller function object and called function object also



Pass by address passes the address of object _________ and pass by reference passes the address of the object _________


aExplicitly, explicitly


b Implicitly, implicitly


cExplicitly, Implicitly


dImplicitly, explicitly



If an object is passed by value _____________


aA new copy of object is created implicitly


bThe object itself is used


c Address of the object is passed


dA new object is created with new random values



Goto Page No.

Page 30 of 93

Alphabetical MCQs Categories

Here below You find all kind of categories of MCQs in alphabetical order.


"Comprehensive Collection of MCQs: Alphabetically Organized by Subject"

"Discover an extensive collection of multiple-choice questions (MCQs) neatly categorized by subject from A to Z. This resource is designed for anyone eager to explore various topics in a straightforward and organized manner. Whether you're a student preparing for exams, an educator seeking supplementary materials, or simply curious about different subjects, this compilation offers a convenient way to learn and assess your knowledge. With questions arranged alphabetically, navigation is effortless, allowing you to delve into subjects of interest at your own pace. Engage, learn, and expand your understanding with this accessible and comprehensive repository of MCQs!"


BolPakistan

bolpakistan.com.pk includes Job Mcqs and Pak Mcqs is the Top Largest Mcqs Forum in World, in which you can read Mcqs of All Subjects, PPSC test preparation, FPSC, NTS and PPSC PAST PAPERS, PPSC PAST MCQS. A Collection of Repeated MCQs for JOBs seekers.

Copyright © 2024, Designed & Developed by BolPakistan