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

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

Cpp Programming Quiz 128 – How can we make a class abstract?

Question: How can we make a class abstract?
[A]. By making all member functions constant.
[B]. By making at least one member function as pure virtual function.[C]. By declaring it abstract using the static keyword.
[D]. By declaring it abstract using the virtual keyword.

Answer: Option B

Cpp Programming Quiz 128 – How can we make a class abstract? Read More »

Cpp Programming, Objects And Classes

Cpp Programming Quiz 129 – Which of the following statements is correct when a class is inherited privately?

Question: Which of the following statements is correct when a class is inherited privately?
[A]. Public members of the base class become protected members of derived class.
[B]. Public members of the base class become private members of derived class.[C]. Private members of the base class become private members of derived class.
[D]. Public members of the base class become public members of derived class.

Answer: Option B

Cpp Programming Quiz 129 – Which of the following statements is correct when a class is inherited privately? Read More »

Cpp Programming, Objects And Classes