Cpp Programming Quiz 41 – A reference is declared using the _____ symbol.
[B]. &[C]. ||
[D]. !
Answer: Option B
Answer: Option B
#include
class BixBase
{
public:
BixBase()
{
cout<< "Base OK. ";
}
~BixBase()
{
cout<< "Base DEL. ";
}
};
class BixDerived: public BixBase
{
public:
BixDerived()
{
cout<< "Derived OK. ";
}
~BixDerived()
{
cout<< "Derived DEL. ";
}
};
int main()
{
BixBase *basePtr = new BixDerived();
delete basePtr;
return 0;
}
[A].Base OK. Derived OK.
[B].Base OK. Derived OK. Base DEL.
[C].Base OK. Derived OK. Derived DEL.
[D].Base OK. Derived OK. Derived DEL. Base DEL.
Answer: Option B
Answer: Option B
#include
#include
class IndiaBix
{
char str[50];
char tmp[50];
public:
IndiaBix(char *s)
{
strcpy(str, s);
}
int BixFunction()
{
int i = 0, j = 0;
while(*(str + i))
{
if(*(str + i++) == ' ')
*(tmp + j++) = *(str + i);
}
*(tmp + j) = 0;
return strlen(tmp);
}
};
int main()
{
char txt[] = "Welcome to IndiaBix.com!";
IndiaBix objBix(txt);
cout<< objBix.BixFunction();
return 0;
}
[A].1
[B].2
[C].24
[D].25
Answer: Option B
Answer: Option C
#include
class BixArray
{
int array[3][3];
public:
BixArray(int arr[3][3] = NULL)
{
if(arr != NULL)
for(int i = 0; i < 3; i++)
for(int j = 0; j < 3; j++)
array[i][j] = i+j;
}
void Display(void)
{
for(int i = 0; i < 3; i++)
for(int j = 0; j < 3; j++)
cout<< array[i][j] << " ";
}
};
int main()
{
BixArray objBA;
objBA.Display();
return 0;
}
[A].The program will report error on compilation.
[B].The program will display 9 garbage values.
[C].The program will display NULL 9 times.
[D].The program will display 0 1 2 1 2 3 2 3 4.
Answer: Option B
#include
class IndiaBix
{
int x;
public:
IndiaBix()
{
x = 0;
}
IndiaBix(int xx)
{
x = xx;
}
IndiaBix(IndiaBix &objB)
{
x = objB.x;
}
void Display()
{
cout<< x << " ";
}
};
int main()
{
IndiaBix objA(25);
IndiaBix objB(objA);
IndiaBix objC = objA;
objA.Display();
objB.Display();
objC.Display();
return 0;
}
[A].The program will print the output 25 25 25 .
[B].The program will print the output 25 Garbage 25 .
[C].The program will print the output Garbage 25 25 .
[D].The program will report compile time error.
Answer: Option A