C C /C Programming -Constructors and Destructors Sample Test,Sample questions

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

1.constructor

2.destructor

3.assignment function

4.copy constructor


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

1.logical

2.virtual

3.syntax

4.linker


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

1.constructor

2. virtual function

3.destructor

4.main


Question:
 
Which of the following statements are correct?

1.Constructor is always called explicitly.

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

3.Destructor is always called explicitly.

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


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

1.different

2.same

3.virtual

4.class


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

1.default constructor

2.copy constructor

3. Both A and B

4.None of these


Question:
  
How many default constructors per class are possible?

1.Only one

2.Two

3.Three

4.Unlimited


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

1.Preprocessor

2.Compiler

3.Linker

4. main() function


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

1. destructor

2.delete

3. delete[]

4.kill[]


Question:
A destructor takes __________ arguments.

1.one

2.two

3.three

4.no


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

1.constructor

2.destructor

3.function

4.object


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

1. cannot overloaded

2.can be overloaded

3. can be called

4. can be nested


Question:
Copy constructor must receive its arguments by __________ .

1.either pass-by-value or pass-by-reference

2.only pass-by-value

3.only pass-by-reference

4.only pass by address


Question:
Destructor calls are made in which order of the corresponding constructor calls?

1.Reverse order

2.Forward order

3.Depends on how the object is constructed

4. Depends on how many objects are constructed


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

1.!

2.?

3.~

4.$


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

1.are called

2.are inherited

3.are not called

4. are created


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

1.enter and leave scope

2. inherit parent class

3.are constructed

4.are destroyed


Question:
How many times a constructor is called in the life-time of an object?

1.Only once

2.Twice

3.Thrice

4.Depends on the way of creation of object


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

1.call one-argument constructor of the class

2.work without any problem

3.call itself recursively

4.call zero-argument constructor


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

1.one

2.two

3.no

4.three


Question:
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?

1.Compile-time error.

2.Preprocessing error.

3.Runtime error.

4.Runtime exception.


Question:
When are the Global objects destroyed?

1.When the control comes out of the block in which they are being used.

2.When the program terminates.

3.When the control comes out of the function in which they are being used.

4.As soon as local objects die.


Question:
Which constructor function is designed to copy objects of the same class type?

1.Create constructor

2.Object constructor

3.Dynamic constructor

4.Copy constructor


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

1.Zero-argument Constructor

2.Destructor

3.Copy Constructor

4.Copy Destructor


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

1.Constructor

2.Destructor

3.Data Members

4.Both A and C


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

1.constructor

2.destructor

3.main

4.virtual function


Question:
Which of the following implicitly creates a default constructor when the programmer does not explicitly define at least one constructor for a class?

1.Preprocessor

2.Linker

3.Loader

4.Compiler


Question:
Which of the following never requires any arguments?

1.Member function

2. Friend function

3.Default constructor

4.const function


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

1.A constructor has a return type.

2.A constructor cannot contain a function call.

3.A constructor has no return type.

4.A constructor has a void return type.


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

1.A destructor has void return type.

2.A destructor has integer return type.

3.A destructor has no return type.

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


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

1. The default constructor of the object is called.

2.The parameterized destructor is called.

3.The default destructor of the object is called.

4.None of the above.


Question:
Which of the following statement is correct?

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

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

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

4. Both A and B.


Question:
Which of the following statement is correct?

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

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

3.Both A and B.

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


Question:
Which of the following statement is correct?

1.Destructor destroys only integer data members of the object.

2.Destructor destroys only float data members of the object.

3. Destructor destroys only pointer data members of the object.

4.Destructor destroys the complete object.


Question:
Which of the following statement is correct?

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

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

3.A destructor always returns an integer.

4.A destructor can be overloaded.


Question:
Which of the following statement is correct?

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

2. A constructor has a different name than the class in which it is present.

3. A constructor always returns an integer.

4.A constructor cannot be overloaded.


Question:
Which of the following statement is incorrect?

1.Constructor is a member function of the class.

2.The compiler always provides a zero argument constructor.

3.It is necessary that a constructor in a class should always be public.

4. Both B and C.


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

1.constructor

2.copy constructor

3.destructor

4.default constructor


More MCQS

  1. C++ Programming MCQS Set-1
  2. C++ Multiple Choice Questions Set-1
  3. C++ Multiple Choice Questions Set-2
  4. C++ Programming MCQS Set-2
  5. C++ Programming MCQS Set-3
  6. C++ Programming MCQS Set-4
  7. C++ (CPP) MCQ Question with Answer
  8. Advanced c++ multiple choice question(MCQS)
  9. OOPS Quiz Questions and Answers(MCQS)
  10. C Programming - MCQ Questions Set 1
  11. C Programming - MCQ Questions Set 2
  12. C Programming - MCQ Questions Set 3
  13. C Programming - MCQ Questions Set 4
  14. C Programming - MCQ Questions Set 5
  15. C++ programming language MCQ Questions Set 1
  16. C++ programming language MCQ Questions Set 2
  17. C++ programming language MCQ Questions Set 3
  18. C++ programming language MCQ Questions Set 4
  19. C++ programming language MCQ Questions Set 5
  20. C++ Programming -Constructors and Destructors
  21. C++ Programming -OOPS Concepts
  22. C++ Programming - References
  23. C++ Programming - Functions
  24. C MCQS:-The ABC of C
  25. C MCQS Interview Questions
  26. C++ Questions and Answers OOPs Basic Concepts
  27. C++ Questions and Answers Returning Objects
  28. C Programming MCQ Part 1
  29. C Programming MCQ
  30. Computer Science & Engineering C Multiple Choice Questions set 1
  31. Computer Science & Engineering C Multiple Choice Questions set 2
  32. C Multiple Choice Questions C Functions Set 1
  33. C Multiple Choice Questions C Functions Set 2
  34. C Multiple Choice Questions C Operators
  35. C Multiple Choice Questions & AnswersConditional Expressions
  36. C Multiple Choice Questions & Answers Data Types
  37. C Multiple Choice Questions & Answers File Access
  38. Computer Science & Engineering Cloud Computing MCQs Part 1
  39. CPP Programming MCQ Set 1
  40. CPP Programming MCQ Set 2
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!