Back-End Programming Exam  >  Back-End Programming Tests  >  Test: Constructor And Destructor - 2 - Back-End Programming MCQ

Test: Constructor And Destructor - 2 - Back-End Programming MCQ


Test Description

15 Questions MCQ Test - Test: Constructor And Destructor - 2

Test: Constructor And Destructor - 2 for Back-End Programming 2024 is part of Back-End Programming preparation. The Test: Constructor And Destructor - 2 questions and answers have been prepared according to the Back-End Programming exam syllabus.The Test: Constructor And Destructor - 2 MCQs are made for Back-End Programming 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: Constructor And Destructor - 2 below.
Solutions of Test: Constructor And Destructor - 2 questions in English are available as part of our course for Back-End Programming & Test: Constructor And Destructor - 2 solutions in Hindi for Back-End Programming course. Download more important topics, notes, lectures and mock test series for Back-End Programming Exam by signing up for free. Attempt Test: Constructor And Destructor - 2 | 15 questions in 30 minutes | Mock test for Back-End Programming preparation | Free important questions MCQ to study for Back-End Programming Exam | Download free PDF with solutions
Test: Constructor And Destructor - 2 - Question 1

C++ provides a special ………………… called the constructor, which enables an object to initialize itself when it is created.

Test: Constructor And Destructor - 2 - Question 2

Which is the correct form of default constructor for following class?

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: Constructor And Destructor - 2 - Question 3

Constructors are normally used to …………….. and to allocate memory.

Test: Constructor And Destructor - 2 - Question 4

What will be the output of following program?

Test: Constructor And Destructor - 2 - Question 5

Constructors cannot be inherited, through a derived class can call the ………………. constructor.

Test: Constructor And Destructor - 2 - Question 6

Does assignment operator implement automatically with the class?

Detailed Solution for Test: Constructor And Destructor - 2 - Question 6

Yes
If we do not implement the assignment operator, it automatically added to the class.

Test: Constructor And Destructor - 2 - Question 7

The constructors that can take arguments are called …………… constructors.

Test: Constructor And Destructor - 2 - Question 8

What will be the output of the following code?

#include <iostream>
using namespace std;

//class definition
class Example {
public:
    Example()
    {
        cout << "Constructor called ";
    }
};

//main() code
int main()
{
    Example Ex1, Ex2;
    return 0;
}

Detailed Solution for Test: Constructor And Destructor - 2 - Question 8

In the class definition, the constructor is public, so there is no any compile time or run time error. We are creating two objects “Ex1” and “Ex2” of “Example” class; constructor will be called two times. Thus, the output will be "Constructor called Constructor called".

Test: Constructor And Destructor - 2 - Question 9

In C++, ……………………. creates objects, even through it was not defined in the class.

Test: Constructor And Destructor - 2 - Question 10

A constructor is called when an object is being created?

Detailed Solution for Test: Constructor And Destructor - 2 - Question 10

No matter, you have created constructors or not in the class, if there is no constructor created by you, constructors are added to the class and when we an object is being created constructor gets called.

Test: Constructor And Destructor - 2 - Question 11

The ………………… constructor can be called with either one argument or no arguments.

Test: Constructor And Destructor - 2 - Question 12

When a destructor is called?

Detailed Solution for Test: Constructor And Destructor - 2 - Question 12

When an object is being destroyed, destructor is called.

Test: Constructor And Destructor - 2 - Question 13

A ……………. takes a reference to an object of the same class as itself as an argument.

Test: Constructor And Destructor - 2 - Question 14

What will be the output of the following code?

#include <iostream>
using namespace std;

//class definition
class Example {
private:
    int a;
    int b;

public:
    Example(int a, int b)
    {
        this->a = a;
        this->b = b;
    }
    int get_a()
    {
        return a;
    }
    int get_b()
    {
        return b;
    }
};

//main() code
int main()
{
    Example Ex(10, 20);
    cout << "a = " << Ex.get_a() << ", b = " << Ex.get_b();

    return 0;
}

Detailed Solution for Test: Constructor And Destructor - 2 - Question 14

a = 10, b = 20
There is no error in the program; we created a parameterized constructor and created only an object with the parameters.

Test: Constructor And Destructor - 2 - Question 15

A destructor is used to destroy the objects that have been created by a ………………..

Information about Test: Constructor And Destructor - 2 Page
In this test you can find the Exam questions for Test: Constructor And Destructor - 2 solved & explained in the simplest way possible. Besides giving Questions and answers for Test: Constructor And Destructor - 2, EduRev gives you an ample number of Online tests for practice
Download as PDF