Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by whitelisting our website.

C++ Programming

Cpp Programming Quiz 118 – What will be the output of the following program?

Question: What will be the output of the following program?

#include
class India
{
public:
struct Bix
{
int x;
float y;
void Function(void)
{
y = x = (x = 4*4);
y = --y * y;
}
void Display()
{
cout<< y << endl; } }B; }I; int main() { I.B.Display(); return 0; }

[A].0
[B].1
[C].-1
[D].Garbage value 

Answer: Option A

Cpp Programming Quiz 118 – What will be the output of the following program? Read More »

Cpp Programming, Objects And Classes

Cpp Programming Quiz 119 – Which of the following statements is correct about the program given below?

Question: Which of the following statements is correct about the program given below?

class Bix
{
public:
static void MyFunction();
};
int main()
{
void(*ptr)() = &Bix::MyFunction;
return 0;
}

[A].The program reports an error as pointer to member function cannot be defined outside the definition of class.
[B].The program reports an error as pointer to static member function cannot be defined.
[C].The program reports an error as pointer to member function cannot be defined without object.
[D].The program reports linker error. 

Answer: Option D

Cpp Programming Quiz 119 – Which of the following statements is correct about the program given below? Read More »

Cpp Programming, Objects And Classes

Cpp Programming Quiz 120 – What does a class hierarchy depict?

Question: What does a class hierarchy depict?
[A].It shows the relationships between the classes in the form of an organization chart.
[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

Cpp Programming Quiz 120 – What does a class hierarchy depict? Read More »

Cpp Programming, Objects And Classes

Cpp Programming Quiz 122 – Which of the following statements about virtual base classes is correct?

Question: Which of the following statements about virtual base classes is correct?
[A]. It is used to provide multiple inheritance.
[B]. It is used to avoid multiple copies of base class in derived class.[C]. It is used to allow multiple copies of base class in a derived class.
[D]. It allows private members of the base class to be inherited in the derived class.

Answer: Option B

Cpp Programming Quiz 122 – Which of the following statements about virtual base classes is correct? Read More »

Cpp Programming, Objects And Classes

Cpp Programming Quiz 123 – What does the class definitions in following code represent?

Question: What does the class definitions in following code represent?

class Bike
{
Engine objEng;
};
class Engine
{
float CC;
};

[A].kind of relationship
[B].has a relationship
[C].Inheritance
[D].Both A and B

Answer: Option B

Cpp Programming Quiz 123 – What does the class definitions in following code represent? Read More »

Cpp Programming, Objects And Classes

Cpp Programming Quiz 124 – What happens when we try to compile the class definition in following code snippet?

Question: What happens when we try to compile the class definition in following code snippet?

class Birds {};
class Peacock : protected Birds {};

[A].[ez-toc] It will not compile because class body of Birds is not defined.
[B].It will not compile because class body of Peacock is not defined.
[C].It will not compile because a class cannot be protectedly inherited from other class.
[D].It will compile succesfully.

Answer: Option D

Cpp Programming Quiz 124 – What happens when we try to compile the class definition in following code snippet? Read More »

Cpp Programming, Objects And Classes

Cpp Programming Quiz 125 – Which of the following statement is correct regarding destructor of base class?

Question: Which of the following statement is correct regarding destructor of base class?
[A].Destructor of base class should always be static.
[B].Destructor of base class should always be virtual.[C].Destructor of base class should not be virtual.
[D].Destructor of base class should always be private.

Answer: Option B

Cpp Programming Quiz 125 – Which of the following statement is correct regarding destructor of base class? Read More »

Cpp Programming, Objects And Classes

Cpp Programming Quiz 127 – Which of the following means “The use of an object of one class in definition of another class”?

Question: Which of the following means “The use of an object of one class in definition of another class”?
[A]. Encapsulation
[B]. Inheritance[C]. Composition
[D]. Abstraction

Answer: Option C

Cpp Programming Quiz 127 – Which of the following means “The use of an object of one class in definition of another class”? Read More »

Cpp Programming, Objects And Classes