Cpp Programming 72 – Which of the following are available only in the class hierarchy chain?
[B]. Private data members[C]. Protected data members
[D]. Member functions
Answer: Option C
Answer: Option C
Answer: Option C
class Bike
{
Engine objEng;
};
class Engine
{
float CC;
};
[A].kind of relationship
[B].has a relationship
[C].Inheritance
[D].Both A and B
Answer: Option B
#include
class IndiaBix
{
int x, y;
public:
void SetValue(int &xx, int &yy)
{
x = xx++;
y = yy;
cout<< xx << " " << yy;
}
};
int main()
{
int x = 10;
int &y = x;
IndiaBix objBix;
objBix.SetValue(x , y);
return 0;
}[A].The program will print the output 10 10.
[B].The program will print the output 10 11.
[C].The program will print the output 11 10.
[D].The program will print the output 11 11.
Answer: Option D
[A].Only 1 is correct.
[B].Only 2 is correct.[C].Both 1 and 2 are correct.
[D].Both 1 and 2 are incorrect.
Answer: Option B
Answer: Option D
#include
class BixBase
{
int x, y;
public:
BixBase(int xx = 10, int yy = 10)
{
x = xx;
y = yy;
}
void Show()
{
cout<< x * y << endl;
}
};
class BixDerived : public BixBase
{
private:
BixBase objBase;
public:
BixDerived(int xx, int yy) : BixBase(xx, yy)
{
objBase.Show();
}
};
int main()
{
BixDerived objDev(10, 20);
return 0;
}
[A].The program will print the output 100.
[B].The program will print the output 200.
[C].The program will print the output Garbage-value.
[D].The program will report compile time error.
Answer: Option A