1. Copy constructor is a constructor which ________________
A. Creates an object by copying values from any other object of same class
B. Creates an object by copying values from first object created for that class
C. Creates an object by copying values from another object of another class
D. Creates an object by initializing it with another previously created object of same class
Correct Answer is : Creates an object by initializing it with another previously created object of same class
2. The copy constructor can be used to:
A. Initialize one object from another object of same type
B. Initialize one object from another object of different type
C. Initialize more than one object from another object of same type at a time
D. Initialize all the objects of a class to another object of another class
Correct Answer is : Initialize one object from another object of same type
3. 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?
B. Yes, because the members are same
D. No, but possible if constructor is also same
Correct Answer is : No, not possible
4. The copy constructors can be used to ________
A. Copy an object so that it can be passed to a class
B. Copy an object so that it can be passed to a function
C. Copy an object so that it can be passed to another primitive type variable
D. Copy an object for type casting
Correct Answer is : Copy an object so that it can be passed to a function
5. Which returning an object, we can use ____________
B. Zero argument constructor
C. Parameterized constructor
Correct Answer is : Copy constructor
6. If programmer doesn’t define any copy constructor then _____________
A. Compiler provides an implicit copy constructor
B. Compiler gives an error
C. The objects can’t be assigned with another objects
D. The program gives run time error if copying is used
Correct Answer is : Compiler provides an implicit copy constructor
7. If a class implements some dynamic memory allocations and pointers then _____________
A. Copy constructor must be defined
B. Copy constructor must not be defined
C. Copy constructor can’t be defined
D. Copy constructor will not be used
Correct Answer is : Copy constructor must be defined
8. What is the syntax of copy constructor?
A. classname (classname &obj){ /*constructor definition*/ }
B. classname (cont classname obj){ /*constructor definition*/ }
C. classname (cont classname &obj){ /*constructor definition*/ }
D. classname (cont &obj){ /*constructor definition*/ }
Correct Answer is : classname (cont classname &obj){ /*constructor definition*/ }
9. Object being passed to a copy constructor ___________
A. Must be passed by reference
B. Must be passed by value
C. Must be passed with integer type
D. Must not be mentioned in parameter list
Correct Answer is : Must be passed by reference
10. Out of memory error is given when the object _____________ to the copy constructor.
A. Is passed with & symbol
B. Is passed by reference
D. Is not passed by reference
Correct Answer is : Is not passed by reference
11. Copy constructor will be called whenever the compiler __________
A. Generates implicit code
B. Generates member function calls
C. Generates temporary object
D. Generates object operations
Correct Answer is : Generates temporary object
12. The deep copy is possible only with the help of __________
A. Implicit copy constructor
B. User defined copy constructor
C. Parameterized constructor
Correct Answer is : User defined copy constructor
13. Can a copy constructor be made private?
B. Yes, if no other constructor is defined
D. No, private members can’t be accessed
Correct Answer is : Yes, always
14. The arguments to a copy constructor _____________
Correct Answer is : Must be const
15. Copy constructors are overloaded constructors.
16. What is the term used to indicate the variable and constants of a class?
Correct Answer is : Data members
17. Data members ________________ (C++)
A. Can be initialized with declaration in classes
B. Can be initialized only with help of constructors
C. Can be initialized either in declaration or by constructor
Correct Answer is : Can be initialized only with help of constructors
18. Which among the following is true for data members?
A. Private data members can be initialized with declaration in class
B. Static members are initialized in constructors
C. Protected data members can be initialized in class directly
D. Static data members are defined outside class, not in constructor
Correct Answer is : Static data members are defined outside class, not in constructor
19. What should be done for data member to be of user defined structure type?
A. The structure must have been defined before class.
B. The structure must have been defined after the class definition
C. The structure must be predefined
D. The structure type data members can’t be used
Correct Answer is : The structure must have been defined before class.
20. How many data members can a class contain?
Correct Answer is : As many as required