Cpp Programming Quiz 49 – In which of the following a virtual call is resolved at the time of compilation?
[B]. From inside the constructor.[C]. From inside the main().
[D]. Both A and B.
Answer: Option D
Answer: Option D
Answer: Option B
inherit parent class
[C].
are constructed
[D].
are destroyed
Answer: Option A
Explanation:
No answer description available for this question.
#include
#include
{
static int x;
public:
IndiaBix()
{
if(x == 1)
exit(0);
else
x++;
}
void Display()
{
cout<< x << " ";
}
};
int IndiaBix::x = 0;
int main()
{
IndiaBix objBix1;
objBix1.Display();
IndiaBix objBix2;
objBix2.Display();
return 0;
}
[A].The program will print the output 1 2.
[B].The program will print the output 0 1.
[C].The program will print the output 1 1.
[D].The program will print the output 1.
Answer: Option D
Answer: Option C
#include
class IndiaBix
{
public:
void Bix(int x = 15)
{
x = x/2;
if(x > 0)
Bix();
else
cout<< x % 2;
}
};
int main()
{
IndiaBix objIB;
objIB.Bix();
return 0;
}
[A]. The program will display 1.
[B]. The program will display 2.
[C]. The program will display 15.
[D]. The program will go into an infinite loop.
Answer: Option D
#include
int main()
{
float Amount;
float Calculate(float P = 5.0, int N = 2, float R = 2.0);
Amount = Calculate();
cout<< Amount << endl;
return 0;
}
float Calculate(float P, int N, float R)
{
int Year = 1;
float Sum = 1 ;
Sum = Sum * (1 + P * ++N * R);
Year = (int)(Year + Sum);
return Year;
}
[A].21
[B].22
[C].31
[D].32
Answer: Option D