Which of the following statement is correct about the program given

Loading

Practice Function Overloading –

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

#include  
class LGArray {
int array[3][3];
public:
LGArray(int arr[3][3] = NULL) {
if(arr != NULL) {
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 3; j++) {
array[i][j] = i+j;
}
}
}
}
void Display(void) {
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 3; j++) {
cout<< array[i][j] << " ";
}
}
}
};
int main() {
LGArray objBA;
objBA.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 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 Functions –

What will be the output of the following program?

#include 
#include
class TryString {
char x[50];
char y[50];
char z[50];
public:
TryString() { }
TryString(char* xx) {
strcpy(x, xx);
strcpy(y, xx);
}
TryString(char *xx, char *yy = " C++", char *zz = " Programming!") {
strcpy(z, xx);
strcat(z, yy);
strcat(z, zz);
}
void Display(void) {
cout<< z << endl;
}
};
int main() {
TryString objStr("Learn", " Java");
objStr.Display();
return 0;
}

What will be the output of the following program?

Loading

Practice Functions –

What will be the output of the following program?

#include 
class TestDrive {
int x;
public:
TestDrive(int xx) {
x = xx;
}
int DriveIt(void);
};
int TestDrive::DriveIt(void) {
static int value = 0;
int m;
m = x % 2;
x = x / 2;
if((x / 2)) {
DriveIt();
}
value = value + m * 10;
return value;
}
int main() {
TestDrive TD(1234);
cout<< TD.DriveIt() * 10 << endl;
return 0;
}

What will be the output of the following program?

Loading

Practice Functions –

What will be the output of the following program?

#include  
class AreaFinder {
float l, b, h;
float result;
public:
AreaFinder(float hh = 0, float ll = 0, float bb = 0) {
l = ll;
b = bb;
h = hh;
}
void Display(int ll) {
if(l = 0) {
result = 3.14f * h * h;
}
else {
result = l * b;
cout<< result;
}
}
};
int main() {
AreaFinder objAF(10, 10, 20);
objAF.Display(0);
return 0;
}

What will be the output of the following program?

Loading

Practice OOPS Concepts –

What will be the output of the following program?

#include 
class Crackexams {
int x, y, z;
public:
void Apply(int xx = 12, int yy = 21, int zz = 9) {
x = xx;
y = yy += 10;
z = x -= 2;
}
void Display(void) {
cout<< x << " " << y << endl;
}
void SetValue(int xx, int yy) {
Apply(xx, 0, yy);
}
};
int main() {
Crackexams *pCrackexams= new Crackexams;
(*pCrackexams).SetValue(12, 20);
pCrackexams->Display();
delete pCrackexams;
return 0;
}

Which of the following statement is correct about the program given

Loading

Practice OOPS Concepts –

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

#include 
class Crackexams {
int x, y, z;
public:
Crackexams(int x = 100, int y = 30, int z = 0) {
this->x = x;
this->y = y;
this->z = z;
Display();
}
void Display() {
cout<< x << " " << y << " " << z;
}
};
int main() {
int a = 0, b = 1, c = 2;
int &x = ++a;
int &y = --b;
int z = c + b - -c;
Crackexams objCrackexams(x, y, z);
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;
}

What will be the output of following program? 

Loading

Practice Memory Management –

What will be the output of following program? 

#include
void main()
{
float x;
x=(float)9/2;
cout< }

What is the output of following program?


			  		

Loading

Practice Memory Management –

What is the output of following program?

#include 
using namespace std;

class A
{
private:
int x;
public:
A(int _x) { x = _x; }
int get() { return x; }
};

class B
{
static A a;
public:
static int get()
{ return a.get(); }
};

int main(void)
{
B b;
cout << b.get();
return 0;
}

What is the output of following program?


			  		

Loading

Practice Memory Management –

What is the output of following program?

#include 
using namespace std;

class Player
{
private:
int id;
static int next_id;
public:
int getID() { return id; }
Player() { id = next_id++; }
};
int Player::next_id = 1;

int main()
{
Player p1;
Player p2;
Player p3;
cout << p1.getID() << " ";
cout << p2.getID() << " ";
cout << p3.getID();
return 0;
}