Cpp Programming Quiz 47 – Which of the following type of class allows only one object of it to be created?
[B]. Abstract class[C]. Singleton class
[D]. Friend class
Answer: Option C
Answer: Option C
Compiler
[C].
Linker
[D].
main() function
Answer: Option B
Explanation:
No answer description available for this question.
Answer: Option C
#include
class IndiaBix
{
int x;
float y;
public:
IndiaBix(int x)
{
x = x;
}
IndiaBix(int p = 0, int q = 10)
{
x = p += 2;
y = q * 1.0f;
}
void SetValue(int &y, float z)
{
x = y;
y = (int)z;
}
void Display(void)
{
cout<< x;
}
};
int main()
{
int val = 12;
IndiaBix objBix(val);
IndiaBix objTmp();
objBix.SetValue(val, 3.14f);
objBix.Display();
return 0;
}
[A].The program will print the output 2.
[B].The program will print the output 12.
[C].The program will report run time error.
[D].The program will not compile successfully.
Answer: Option D
#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 constructor cannot contain a function call.
[C].
A constructor has no return type.
[D].
A constructor has a void return type.
Answer: Option C
Explanation:
No answer description available for this question.
Answer: Option B