Object Oriented Programming MCQs

Page No. 14

What is the syntax of copy constructor?


a classname (classname &obj){ /*constructor definition*/ }


bclassname (cont classname obj){ /*constructor definition*/ }


cclassname (cont classname &obj){ /*constructor definition*/ }


dclassname (cont &obj){ /*constructor definition*/ }



If a class implements some dynamic memory allocations and pointers then _____________


a Copy constructor must be defined


bCopy constructor must not be defined


cCopy constructor can’t be defined


dCopy constructor will not be used



If programmer doesn’t define any copy constructor then _____________


aCompiler provides an implicit copy constructor


bCompiler gives an error


cThe objects can’t be assigned with another objects


dThe program gives run time error if copying is used



Which returning an object, we can use ____________


aDefault constructor


bZero argument constructor


cParameterized constructor


dCopy constructor


View Answer Copy constructor

The copy constructors can be used to ________


aCopy an object so that it can be passed to a class


bCopy an object so that it can be passed to a function


cCopy an object so that it can be passed to another primitive type variable


d Copy an object for type casting



If two classes have exactly same data members and member function and only they differ by class name. Can copy constructor be used to initialize one class object with another class object?


a Yes, possible


bYes, because the members are same


cNo, not possible


dNo, but possible if constructor is also same


View Answer No, not possible

The copy constructor can be used to ____________


aInitialize one object from another object of same type


bInitialize one object from another object of different type


cInitialize more than one object from another object of same type at a time


dInitialize all the objects of a class to another object of another class



Copy constructor is a constructor which ________________


aCreates an object by copying values from any other object of same class


bCreates an object by copying values from first object created for that class


cCreates an object by copying values from another object of another class


dCreates an object by initializing it with another previously created object of same class



Which is correct syntax?


aclassname objectname= new() integer;


bclassname objectname= new classname;


cclassname objectname= new classname();


dclassname objectname= new() classname();



What are we only create an object but don’t call any constructor for it in java?


aImplicit constructor will be called


bObject is initialized to some null values


cObject is not created


dObject is created but points to null



Goto Page No.

Page 14 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