C++ Programming - References
Exercise : References - Programs
- References - General Questions
- References - Programs
21.
Which of the following statement is correct about the program given below?
#include<iostream.h>
int i, j;
class IndiaBix
{
public:
IndiaBix(int x = 0, int y = 0)
{
i = x;
j = x;
Display();
}
void Display()
{
cout<< j <<" ";
}
};
int main()
{
IndiaBix objBix(10, 20);
int &s = i;
int &z = j;
i++;
cout<< s-- << " " << ++z;
return 0;
}
22.
Which of the following statement is correct about the program given below?
#include<iostream.h>
int x, y;
class BixTest
{
public:
BixTest(int xx = 0, int yy = 0)
{
x = xx;
y = yy;
Display();
}
void Display()
{
cout<< x << " " << y << " ";
}
};
int main()
{
BixTest objBT(10, 20);
int &rx = x;
int &ry = y;
ry = x;
rx = y;
cout<< rx--;
return 0;
}
23.
Which of the following statement is correct about the program given below?
#include<iostream.h>
class IndiaBix
{
int a, b, c;
public:
void SetValue(int x, int y ,int z)
{
a = x;
b = y;
c = z;
}
void Display()
{
cout<< a << " " << b << " " << c;
}
};
int main()
{
IndiaBix objBix;
int x = 2;
int &y = x;
y = 5;
objBix.SetValue(x, ++y, x + y);
objBix.Display();
return 0;
}
24.
What will be the output of the program given below?
#include<iostream.h>
class BixBase
{
int x;
public:
BixBase(int xx = 0)
{
x = xx;
}
void Display()
{
cout<< x ;
}
};
class BixDerived : public BixBase
{
int y;
public:
BixDerived(int yy = 0)
{
y = yy;
}
void Display()
{
cout<< y ;
}
};
int main()
{
BixBase objBase(10);
BixBase &objRef = objBase;
BixDerived objDev(20);
objRef = objDev;
objDev.Display();
return 0;
}
25.
Which of the following statement is correct about the program given below?
#include<iostream.h>
class IndiaBix
{
int x, y;
public:
IndiaBix(int xx = 0, int yy = 0)
{
x = xx;
y = yy;
}
void Display()
{
cout<< x << " " << y;
}
IndiaBix operator +(IndiaBix z)
{
IndiaBix objTemp;
objTemp.x = x + z.x;
objTemp.y = y + z.y;
return objTemp;
}
};
int main()
{
IndiaBix objBix1(90, 80);
IndiaBix objBix2(10, 20);
IndiaBix objSum;
IndiaBix &objRef = objSum;
objRef = objBix1 + objBix2;
objRef.Display();
return 0;
}
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers