Cpp Programming Quiz 48 – Which one of the following options is correct?
[B]. Friend function can access protected data members of the class.[C]. Friend function can access private data members of the class.
[D]. All of the above.
Answer: Option D
Answer: Option D
Answer: Option C
#include
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;
}
[A].The program will print the output 0 0 10.
[B].The program will print the output 10 20 10.
[C].The program will print the output 10 20 9.
[D].It will result in a compile time error.
Answer: Option B
Answer: Option B
The program will print the output Garbage-value.
[C].
The program will report compile time error.
[D].
The program will report runtime error.
Answer: Option C
Explanation:
No answer description available for this question.
#include
class IndiaBix
{
static int x;
public:
static void SetData(int xx)
{
this->x = xx;
}
static void Display()
{
cout<< x ;
}
};
int IndiaBix::x = 0;
int main()
{
IndiaBix::SetData(22);
IndiaBix::Display();
return 0;
}
[A].The program will print the output 0.
[B].The program will print the output 22.
[C].The program will print the output Garbage.
[D].The program will report compile time error.
Answer: Option D
#include
class BixBase
{
public:
BixBase()
{
cout<< "Base OK. ";
}
~BixBase()
{
cout<< "Base DEL. ";
}
};
class BixDerived: public BixBase
{
public:
BixDerived()
{
cout<< "Derived OK. ";
}
~BixDerived()
{
cout<< "Derived DEL. ";
}
};
int main()
{
BixBase *basePtr = new BixDerived();
delete basePtr;
return 0;
}
[A].Base OK. Derived OK.
[B].Base OK. Derived OK. Base DEL.
[C].Base OK. Derived OK. Derived DEL.
[D].Base OK. Derived OK. Derived DEL. Base DEL.
Answer: Option B