⟩ Tell me how should a constructor handle a failure?
Throw an exception
Constructors don't have a return type, so it's not possible to use return codes. The best way to signal constructor failure is therefore to throw an exception.
Throw an exception
Constructors don't have a return type, so it's not possible to use return codes. The best way to signal constructor failure is therefore to throw an exception.
Which constructor function is designed to copy objects of the same class type? A. Create constructor B. Object constructor C. Dynamic constructor D. Copy constructor
How many times a constructor is called in the life-time of an object? A. Only once B. Twice C. Thrice D. Depends on the way of creation of object
Which of the following statement is incorrect? A. Constructor is a member function of the class. B. The compiler always provides a zero argument constructor. C. It is necessary that a constructor in a class should always be public. D. Both B and C.
Copy constructor must receive its arguments by __________ . A. either pass-by-value or pass-by-reference B. only pass-by-value C. only pass-by-reference D. only pass by address
When are the Global objects destroyed? A. When the control comes out of the block in which they are being used. B. When the program terminates. C. When the control comes out of the function in which they are being used. D. As soon as local objects die.
Which of the following implicitly creates a default constructor when the programmer does not explicitly define at least one constructor for a class? A. Preprocessor B. Linker C. Loader D. Compiler
Which of the following gets called when an object goes out of scope? A. constructor B. destructor C. main D. virtual function
Which of the following statement is correct? A. A constructor has the same name as the class in which it is present. B. A constructor has a different name than the class in which it is present. C. A constructor always returns an integer. D. A constructor cannot be overloaded.
Which of the following never requires any arguments? A. Member function B. Friend function C. Default constructor D. const function
Destructor calls are made in which order of the corresponding constructor calls? A. Reverse order B. Forward order C. Depends on how the object is constructed D. Depends on how many objects are constructed