Cpp Programming Quiz 63 – Which of the following is a mechanism of static polymorphism?
[B]. Function overloading[C]. Templates
[D]. All of the above
Answer: Option D
Answer: Option D
#include
static int Result;
class India
{
public:
void Change(int x = 10, int y = 20, int z = 30)
{
cout<< x + y + z;
}
void Display(int x = 40, float y = 50.00)
{
Result = x % x;
cout<< Result;
}
};
class Bix
{
int x, y;
public:
void Change(int x, int y = 50)
{
cout<< x + y;
}
};
class IndiaBix: public India, public Bix
{
public:
void Display(int x = 10, int xx = 100, int xxx = 1000)
{
Result = x + xx % x * x;
cout<< Result ;
}
};
int main()
{
IndiaBix objBix;
objBix.India::Display(10, 20.00);
return 0;
}
[A].The program will print the output 0.
[B].The program will print the output 10.
[C].The program will print the output 30.
[D].The program will print the output 40.
Answer: Option A
[B].
[C].
[D].
Answer: Option A
Explanation:
No answer description available for this question.
[B].
[C].
[D].
Answer: Option C
Explanation:
The statement int arr[size]; produces an error, because we cannot initialize the size of array dynamically. Constant expression is required here.
Example: int arr[10];
One more point is there, that is, usually declaration is not allowed after calling any function in a current block of code. In the given program the declaration int arr[10]; is placed after a function call scanf().
#include
class IndiaBix
{
int Num;
public:
IndiaBix(int x)
{
Num = x;
}
int BixFunction(void);
};
int IndiaBix::BixFunction(void)
{
static int Sum = 0;
int Dec;
Dec = Num % 10;
Num = Num / 10;
if((Num / 100)) BixFunction();
Sum = Sum * 10 + Dec;
return Sum;
}
int main()
{
IndiaBix objBix(12345);
cout<< objBix.BixFunction();
return 0;
}
[A].123
[B].321
[C].345
[D].12345
Answer: Option C
A destructor has a different name than the class in which it is present.
[C].
A destructor always returns an integer.
[D].
A destructor can be overloaded.
Answer: Option A
Explanation:
No answer description available for this question.
Answer: Option B