constructors Interview Questions and Answers
Ques:- A destructor name must be
A. same as class name prefixed by tilde (~) character
B. same as class name
C. same as any other member function name
D. none of the given
Ques:- Which of the following prototype can be a copy constructor of class myclass?
A. myclass (myclass & ×)
B. myclass copy (myclass a)
C. int copy (myclass mc)
D. myclass (int myclass)
Ques:- A copy constructor is invoked when
A. an object is passed by reference to constructor
B. a member function returns an object
C. an object is passed as a parameter to any of the member function
D. all of the above
Ques:- Which of the following is not true?
A. Destructors cannot be overloaded
B. Constructor can have parameters
C. Constructor is executed automatically
D. Constructor cannot be Overloaded
Ques:- Which of the following is false?
A. Constructor and member function have same name
B. Class and destructor have same name
C. Class and constructor have same name
D. Constructor and destructor have same name
Ques:- Which of the following is automatically executed when the control reaches the end of class scope?
A. Inline function
B. Member function
C. Destructor
D. Constructor
Ques:- Which of the following is a function that removes the allocated memory of an object?
A. Copy constructor
B. Member function
C. Destructor
D. Constructor
Ques:- Which of the following is true?
A. The constructor function can be overloaded
B. The constructor is executed automatically
C. A constructor can have parameter list
D. All the given are true
Ques:- Which one of the following initializes a class object and allocates memory space?
A. Member function
B. Constructor
C. Destructor
D. None of the given
Ques:- Which one of the following is automatically executed when an object is created?
A. Constructor
B. Destructor
C. Inline function
D. Member function
Ques:- The name of constructor must be ___
A. Same as object name
B. Same as one of the member function
C. Same as class name
D. None of the given
Ques:- When an object is passed by reference to constructor, the constructor that is executed is _____
A. Inline
B. Default
C. Static
D. Copy
Ques:- When a class object goes out of scope, the function that gets executed is ____
A. Constructor
B. Destructor
C. Friend
D. Inline
Ques:- Which is executed automatically when the control reaches the end of the class scope?
A. Constructor
B. Destructor
C. Overloading
D. Copy constructor
Ques:- The constructor without any parameter is called as ___
A. Initial constructor
B. Parameterized constructor
C. Default constructor
D. Instance parameter
Ques:- The constructor defined by the computers in the absence of user defined constructor is ____
A. Copy
B. Abstract
C. Default
D. Destructor
Ques:- The constructors defined by the computers in the absence of user defined constructor is called as ____
A. Non-parameterized
B. Default
C. Compiler generated
D. All of these