While returning an object, we can use ____________
Copy constructor
Default constructor
Parameterized constructor
Zero argument constructor
61 practice sets · Page 3 of 4
While returning an object, we can use ____________
Copy constructor
Default constructor
Parameterized constructor
Zero argument constructor
The copy constructors can be used to ________
Copy an object for type casting
Copy an object so that it can be passed to a function
Copy an object so that it can be passed to a class
Copy an object so that it can be passed to another primitive type variable
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?
No, but possible if constructor is also same
Yes, because the members are same
No, not possible
Yes, possible
The copy constructor can be used to ____________
Initialize one object from another object of same type
Initialize all the objects of a class to another object of another class
Initialize one object from another object of different type
Initialize more than one object from another object of same type at a time
Copy constructor is a constructor which ________________
Creates an object by copying values from another object of another class
Creates an object by copying values from first object created for that class
Creates an object by initializing it with another previously created object of same class
Creates an object by copying values from any other object of same class
References to object are same as pointers of object.
False
True
What should be done to prevent changes that may be made to the values pointed by the pointer?
Pointer should be made const
Pointer should be made anonymous
Usual pointer can’t change the values pointed
Pointer should be made virtual
How can the address stored in the pointer be retrieved?
Using * symbol
Using @ symbol
Using $ symbol
Using & symbol
If a pointer to an object is created and the object gets deleted without using the pointer then __________
It becomes void pointer
It becomes dangling pointer
It becomes zero pointer
It becomes null pointer
Which is the correct syntax to call a member function using pointer?
pointer::function()
pointer.function()
pointer->function()
pointer:function()
Which among the following is true?
The pointer can’t hold any value
The pointer can hold value of any type
The pointer to object can hold address only
The pointer can hold only void reference
Is name of an array of objects is also a pointer to object?
No, because it represents more than one object
Yes, always
No, never
Yes, in few cases
Can pointers to object access the private members of the class?
Yes, always
Yes, only if it is only pointer to object
No, never
No, because objects can be referenced from another objects too
Pointer to a base class can be initialized with the address of derived class, because of _________
base-to-base implicit conversion for pointers
derived-to-derived implicit conversion for pointers
derived-to-base implicit conversion for pointers
base-to-derived implicit conversion for pointers
A pointer _________________
Can point to only 2 objects at a time
Can point to more than one objects at a time
Can point to whole class objects at a time
Can point to only one object at a time
What is the size of an object pointer?
Equal to size of maximum sized member of object
Equal to size of any usual pointer
Equal to size of void
Equal to size of sum of all the members of object
If pointer to an object is declared __________
It can only store address of integer type
It can store only void addresses
It can store any type of address
It can only store object address of class type specified
How does compiler decide the intended object to be used, if more than one object are used?
Using void pointer
Using this pointer
Using object name
Using an integer pointer
Which operator should be used to access the members of the class using object pointer?
Arrow operator
Scope resolution operator
Colon to the member
Dot operator
Which is correct syntax for declaring pointer to object?
className objectName();
className* objectName;
*className objectName;
className objectName;