What will be the output of following program?


			  		

Loading

Practice Constructors and Destructors –

What will be the output of following program?

#include
using namespace std;

class X
{
public:
int x;
};

int main()
{
X a = {10};
X b = a;
cout << a.x << " " << b.x;
return 0;
}

Predict the output of following program?


			  		

Loading

Practice Constructors and Destructors –

Predict the output of following program?

#include
using namespace std;

class Point {
public:
Point() { cout << "Normal Constructor called "; }
Point(const Point &t) { cout << "Copy constructor called "; }
};

int main()
{
Point *t1, *t2;
t1 = new Point();
t2 = new Point(*t1);
Point t3 = *t1;
Point t4;
t4 = t3;
return 0;
}

What will be the output of the following program?

Loading

Practice Constructors and Destructors –

What will be the output of the following program?

#include  
struct Crackexams {
int arr[5];
public:
void TryFunction(void);
void Display(void);
};
void Crackexams::Display(void) {
for(int i = 0; i < 5; i++) {
cout<< arr[i] << " " ;
}
}
void Crackexams::TryFunction(void) {
static int i = 0, j = 4;
int tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp ;
i++;
j--;
if(j != i) {
TryFunction();
}
}
int main() {
Crackexams objTry = {{ 5, 6, 3, 9, 0 }};
objTry.TryFunction();
objTry.Display();
return 0;
}

Which of the following statement is correct about the program given

Loading

Practice Constructors and Destructors –

Which of the following statement is correct about the program given below?

#include 
class Crackexams {
int x;
float y;
public:
Crackexams(int x) {
x = x;
}
Crackexams(int p = 0, int q = 10) {
x = p += 2;
y = q * 1.0f;
}
void SetValue(int &y, float z) {
x = y;
y = (int)z;
}
void Display(void) {
cout<< x;
}
};
int main() {
int val = 12;
Crackexams objCrackexams(val);
Crackexams objTmp();
objCrackexams.SetValue(val, 3.14f);
objCrackexams.Display();
return 0;
}

What will be the output of the following program?

Loading

Practice Constructors and Destructors –

What will be the output of the following program?

#include 
struct CrackexamsArray {
int arr[5];
public:
void CrackexamsFunction();
void Display();
};
void CrackexamsArray::CrackexamsFunction() {
static int i = 0, j = 4;
i++;
j--;
if(j > 0) {
CrackexamsFunction();
}
int tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
i--;
j++;
}
void CrackexamsArray::Display() {
for(int i = 0; i < 5; i++){
cout<< arr[i] << " ";
}
}
int main() {
CrackexamsArray objArr = {{5, 6, 3, 9, 0}};
objArr.CrackexamsFunction();
objArr.Display();
return 0;
}

What will be the output of the following program ?

Loading

Practice Constructors and Destructors –

What will be the output of the following program ?

#include  
class Crackexams {
public:
Crackexams() {
cout<< "Hello";
}
~Crackexams() {
cout<< "India";
}
};
int main() {
Crackexams obj;
return 0;
}

Predict the output of following program.


			  		

Loading

Practice Constructors and Destructors –

Predict the output of following program.

#include 
using namespace std;
class A
{
protected:
int x;
public:
A() {x = 0;}
friend void show();
};

class B: public A
{
public:
B() : y (0) {}
private:
int y;
};

void show()
{
A a;
B b;
cout << "The default value of A::x = " << a.x << " ";
cout << "The default value of B::y = " << b.y;
}

Which of the following statements is correct?

Loading

Practice Constructors and Destructors –

Which of the following statements is correct?

What will be the output of the following program ?

Loading

Practice Constructors and Destructors –

What will be the output of the following program ?

#include<iostream.h>  
class Logic {
public:
Logic() {
cout<< "Hello";
}
~Logic() {
cout<< "India";
}
};
int main() {
Logic obj;
return 0;
}