Cpp Programming Quiz 53 – Which of the following statements is correct?
[B]. Derived class pointer cannot point to base class.[C]. Pointer to derived class cannot be created.
[D]. Pointer to base class cannot be created.
Answer: Option B
Answer: Option B
#include
struct MyData
{
public:
int Addition(int a, int b = 10)
{
return (a *= b + 2);
}
float Addition(int a, float b);
};
int main()
{
MyData data;
cout<
[A].12 12
[B].12 18
[C].3 14
[D].18 12
Answer: Option B
#include
class Base
{
public:
int S, A, M;
Base(int x, int y)
{
S = y - y;
A = x + x;
M = x * x;
}
Base(int, int y = 'A', int z = 'B')
{
S = y;
A = y + 1 - 1;
M = z - 1;
}
void Display(void)
{
cout<< S << " " << A << " " << M << endl;
}
};
class Derived : public Base
{
int x, y, z;
public:
Derived(int xx = 65, int yy = 66, int zz = 67): Base(x)
{
x = xx;
y = yy;
z = zz;
}
void Display(int n)
{
if(n)
Base::Display();
else
cout<< x << " " << y << " " << z << endl;
}
};
int main()
{
Derived objDev;
objDev.Display(-1);
return 0;
}
[A].65 65 65
[B].65 66 67
[C].A A A
[D].A B C
Answer: Option A
Answer: Option B
The program will print the output Int .
[C].
The program will print the output Char .
[D].
The program will print the output Final .
Answer: Option C
Explanation:
No answer description available for this question.
#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;
}
[A].0
[B].314
[C].314.0000
[D].200.0000
Answer: Option A