Constructors and Destructors

Q1: A function with the same name as the class, but preceded with a tilde character (~) is called __________ of that class.

A constructor

B destructor

C function

D object

Q2: How many default constructors per class are possible?

A Only one

B Two

C Three

D Unlimited

Q3: For automatic objects, constructors and destructors are called each time the objects

A enter and leave scope

B inherit parent class

C are constructed

D are destroyed

Q4: Which of the following statements are correct?

A Constructor is always called explicitly.

B Constructor is called either implicitly or explicitly, whereas destructor is always called implicitly.

C Destructor is always called explicitly.

D Constructor and destructor functions are not called at all as they are always inline.

Q5: 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

Q6: A __________ is a constructor that either has no parameters, or if it has parameters, all the parameters have default values.

A default constructor

B copy constructor

C Both A and B

D None of these

Q7: If the programmer does not explicitly provide a destructor, then which of the following creates an empty destructor?

A Preprocessor

B Compiler

C Linker

D main() function

Q8: A constructor that accepts __________ parameters is called the default constructor.

A one

B two

C no

D three

Q9: Which of the following statement is correct?

A A constructor of a derived class can access any public and protected member of the base class.

B Constructor cannot be inherited but the derived class can call them.

C A constructor of a derived class cannot access any public and protected member of the base class.

D Both A and B.

Q10: Which of the following never requires any arguments?

A Member function

B Friend function

C Default constructor

D const function

Q11: Destructor has the same name as the constructor and it is preceded by ______ .

A !

B !

C ~

D $

Q12: 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

Q13: What happens when a class with parameterized constructors and having no default constructor is used in a program and we create an object that needs a zero-argument constructor?

A Compile-time error.

B Preprocessing error.

C Runtime error.

D Runtime exception.

Q14: Which of the following statement is correct about constructors?

A A constructor has a return type.

B A constructor cannot contain a function call.

C A constructor has no return type.

D A constructor has a void return type.

Q15: It is a __________ error to pass arguments to a destructor.

A logical

B virtual

C syntax

D linker

Q16: Destructors __________ for automatic objects if the program terminates with a call to function exit or function abort.

A are called

B are inherited

C are not called

D are created

Q17: Which of the following gets called when an object goes out of scope?

A constructor

B destructor

C main

D virtual function

Q18: 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

Q19: Which of the following statement is correct?

A Destructor destroys only integer data members of the object.

B Destructor destroys only float data members of the object.

C Destructor destroys only pointer data members of the object.

D Destructor destroys the complete object.

Q20: 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

Q21: 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.

Q22: Which of the following statement is correct whenever an object goes out of scope?

A The default constructor of the object is called.

B The parameterized destructor is called.

C The default destructor of the object is called.

D None of the above.

Q23: A union that has no constructor can be initialized with another union of __________ type.

A different

B same

C virtual

D class

Q24: A destructor takes __________ arguments.

A one

B two

C three

D no

Q25: A class's __________ is called when an object is destroyed.

A constructor

B destructor

C assignment function

D copy constructor

Q26: To ensure that every object in the array receives a destructor call, always delete memory allocated as an array with operator __________ .

A destructor

B delete

C delete[]

D kill[]

E free[]

Q27: Constructors __________ to allow different approaches of object construction.

A cannot overloaded

B can be overloaded

C can be called

D can be nested

Q28: Which of the following are NOT provided by the compiler by default?

A Zero-argument Constructor

B Destructor

C Copy Constructor

D Copy Destructor

Q29: Which of the following statement is correct?

A A destructor has the same name as the class in which it is present.

B A destructor has a different name than the class in which it is present.

C A destructor always returns an integer.

D A destructor can be overloaded.

Q30: 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.

Q31: Which of the following statement is correct?

A Constructor has the same name as that of the class.

B Destructor has the same name as that of the class with a tilde symbol at the beginning.

C Both A and B.

D Destructor has the same name as the first member function of the class.

Q32: __________ used to make a copy of one class object from another class object of the same class type.

A constructor

B copy constructor

C destructor

D default constructor

Q33: Which of the following cannot be declared as virtual?

A Constructor

B Destructor

C Data Members

D Both A and C

Q34: Can a class have virtual destructor?

A Yes

B No

Q35: Which of the following statement is correct about destructors?

A A destructor has void return type.

B A destructor has integer return type.

C A destructor has no return type.

D A destructors return type is always same as that of main().

Q36: 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.

Q37: If the copy constructor receives its arguments by value, the copy constructor would

A call one-argument constructor of the class

B work without any problem

C call itself recursively

D call zero-argument constructor

Q38: 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

Q39: Which of the following gets called when an object is being created?

A constructor

B virtual function

C destructor

D main


img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.