Cpp Programming Quiz 142 – Which of the following also known as an instance of a class?
[B]. Object[C]. Member Functions
[D]. Member Variables
Answer: Option B
Answer: Option B
Answer: Option C
[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 x;
float y;
public:
void Function()
{
x = 4;
y = 2.50; delete this;
}
void Display()
{
cout<< x << " " << y;
}
};
int main()
{
IndiaBix *pBix = new IndiaBix();
pBix->Function();
pBix->Function();
pBix->Display();
return 0;
}
[A].The program will print the output 4 2.5.
[B].The program will print the output 4.
[C].The program will report runtime error.
[D].The program will report compile time error.
Answer: Option C
The program will print the output Int .
[C].
The program will print the output Float .
[D].
The program will print the output Final .
Answer: Option B
Explanation:
No answer description available for this question.
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.
#include
class IndiaBix
{
int x, y;
public:
void SetValue(int &a, int &b)
{
a = 100;
x = a;
y = b;
Display();
}
void Display()
{
cout<< x << " " << y;
}
};
int main()
{
int x = 10;
IndiaBix objBix;
objBix.SetValue(x, x);
return 0;
}
[A].The program will print the output 100 10.
[B].The program will print the output 100 100.
[C].The program will print the output 100 garbage.
[D].The program will print two garbage values.
Answer: Option B