Constructors and Destructors Important Questions Class 12

Chapter 4 - Constructors and Destructors in C++

This page contains important questions on Constructors and Destructors in C++ for Class 12 Computer Science students. These questions are useful for AHSEC/ASSEB Class 12 exam preparation

1. What is a Constructor?

Answer :A constructor is a special member function of a class that is automatically called whenever an object of the class is created.Its main purpose is to initialize the data members (variables) of an object.

2. What are the characteristics of a constructor?

Answer :

  • Constructor name must be the same as the class name
  • It has no return type, not even void.
  • A constructor can be overloaded.
  • They are generally declared in the public section.
  • Constructors cannot be inherited.

3.What are the types of constructors?

Answer :The types of constructors are:

  • Default constructor
  • Parameterized constructor
  • Copy constructor

4. What is a default constructor?

Answer :A constructor that does not take any arguments is called a default constructor.

5. What is a parameterized constructor?

Answer :A constructor that accepts arguments (parameters) is called a parameterized constructor. Different objects can be initialized with different values.

6. What is a copy constructor?

Answer :A constructor that creates one object by copying another object of the same class is called a copy constructor.

7. What is constructor overloading?

Answer :A class can have more than one constructor with different parameter lists. This is called constructor overloading.

8.What is a destructor?

Answer : A destructor is a special member function that is automatically executed when an object goes out of scope or is deleted.

9. What does a destructor do?

Answer :Its main purpose is to release resources, free memory, and perform cleanup operations before the object is removed from memory.

10. What are the characteristics of a destructor?

Answer :

A destructor has the following characteristics:

  • It has the same name as the class preceded by the tilde (~) symbol.
  • It does not take any arguments.
  • It does not return any value, not even void.
  • Only one destructor can exist in a class.
  • It cannot be overloaded

12 When is a destructor called?

Answer : A destructor is called automatically in the following situations:

  1. When an object goes out of scope
  2. When the program ends
  3. When a dynamic object is deleted
Scroll to Top