Cpp Programming Quiz 120 – What does a class hierarchy depict?
[B].It describes “has a” relationships.[C].It describes “kind of” relationships.
[D].It shows the same relationship as a family tree.
Answer: Option C
Answer: Option C
Compiler
[C].
Linker
[D].
main() function
Answer: Option B
Explanation:
No answer description available for this question.
#include
class BixArray
{
int Matrix[3][3];
public:
BixArray()
{
for(int i = 0; i<3; i++)
for(int j = 0; j < 3; j++)
Matrix[j][i] = i + j;
}
void Display(void)
{
for(int i = 0; i < 3; i++)
for(int j = 0; j < 3; j++)
cout<< Matrix[j][i] << " ";
}
};
int main()
{
BixArray objBix;
objBix.Display();
return 0;
}
[A].The program will display the output 4 3 2 3 2 1 2 1 0.
[B].The program will display the output 0 1 2 1 2 3 2 3 4.
[C].The program will display the output 9 garbage values.
[D].The program will report error on compilation.
Answer: Option B
Answer: Option B
#include
void Tester(int xx, int yy = 5);
class IndiaBix
{
int x;
int y;
public:
void Tester(int xx, int yy = 5)
{
x = xx;
y = yy;
cout<< ++x % --y;
}
};
int main()
{
IndiaBix objBix;
objBix.Tester(5, 5);
return 0;
}
[A].The program will print the output 0.
[B].The program will print the output 1.
[C].The program will print the output 2.
[D].The program will print the output garbage value.
Answer: Option C
#include
int val = 0;
class IndiaBix
{
public:
IndiaBix()
{
cout<< ++val;
}
~IndiaBix()
{
cout<< val--;
}
};
int main()
{
IndiaBix objBix1, objBix2, objBix3;
{
IndiaBix objBix4;
}
return 0;
}
[A].1234
[B].4321
[C].12344321
[D].12341234
Answer: Option C
#include
#include
class IndiaBix
{
char txtMsg[50];
public:
IndiaBix(char *str = NULL)
{
if(str != NULL)
strcpy(txtMsg, str);
}
int BixFunction(char ch);
};
int IndiaBix::BixFunction(char ch)
{
static int i = 0;
if(txtMsg[i++] == ch)
return strlen((txtMsg + i)) - i;
else
return BixFunction(ch);
}
int main()
{
IndiaBix objBix("Welcome to IndiaBix.com!");
cout<< objBix.BixFunction('t');
return 0;
}
[A].6
[B].8
[C].9
[D].15
Answer: Option A