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 130 – Which of the following is the only technical difference between structures and classes in C++?

Question: Which of the following is the only technical difference between structures and classes in C++?
[A]. Member function and data are by default protected in structures but private in classes.
[B]. Member function and data are by default private in structures but public in classes.[C]. Member function and data are by default public in structures but private in classes.
[D]. Member function and data are by default public in structures but protected in classes.

Answer: Option C

 

Cpp Programming Quiz 130 – Which of the following is the only technical difference between structures and classes in C++? Read More »

Cpp Programming, Objects And Classes

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

Question: Which of the following statements is correct when a class is inherited publicly?
[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 protected members of derived class.
[D]. Public members of the base class become public members of derived class.

Answer: Option D

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

Cpp Programming, Objects And Classes

Cpp Programming Quiz 133 – Which of the following statements is correct about the constructors and destructors?

Question: Which of the following statements is correct about the constructors and destructors?
[A]. Destructors can take arguments but constructors cannot.
[B]. Constructors can take arguments but destructors cannot.[C]. Destructors can be overloaded but constructors cannot be overloaded.
[D]. Constructors and destructors can both return a value.

Answer: Option B

Cpp Programming Quiz 133 – Which of the following statements is correct about the constructors and destructors? Read More »

Cpp Programming, Objects And Classes

Cpp Programming Quiz 135 – Which of the following statements is correct?

Question: Which of the following statements is correct?
[A]. Data items in a class must be private.
[B]. Both data and functions can be either private or public.[C]. Member functions of a class must be private.
[D]. Constructor of a class cannot be private.

Answer: Option B

Cpp Programming Quiz 135 – Which of the following statements is correct? Read More »

Cpp Programming, Objects And Classes

Cpp Programming Quiz 136 – Which of the following statements is incorrect?

Question: Which of the following statements is incorrect?
[A]. Friend keyword can be used in the class to allow access to another class.
[B]. Friend keyword can be used for a function in the public section of a class.[C]. Friend keyword can be used for a function in the private section of a class.
[D]. Friend keyword can be used on main().

Answer: Option D

Cpp Programming Quiz 136 – Which of the following statements is incorrect? Read More »

Cpp Programming, Objects And Classes

Cpp Programming Quiz 137 – Which of the following statements are correct for a static member function?

Question: Which of the following statements are correct for a static member function?
  1. It can access only other static members of its class.
  2. It can be called using the class name, instead of objects.

[A]. Only 1 is correct.
[B]. Only 2 is correct.[C]. Both 1 and 2 are correct.
[D]. Both 1 and 2 are incorrect.

Answer: Option C

Cpp Programming Quiz 137 – Which of the following statements are correct for a static member function? Read More »

Cpp Programming, Objects And Classes

Cpp Programming Quiz 138 – Which of the following can access private data members or member functions of a class?

Question: Which of the following can access private data members or member functions of a class?
[A]. Any function in the program.
[B]. All global functions in the program.[C]. Any member function of that class.
[D]. Only public member functions of that class.

Answer: Option C

Cpp Programming Quiz 138 – Which of the following can access private data members or member functions of a class? Read More »

Cpp Programming, Objects And Classes

Cpp Programming Quiz 139 – Which of the following two entities (reading from Left to Right) can be connected by the dot operator?

Question: Which of the following two entities (reading from Left to Right) can be connected by the dot operator?
[A]. A class member and a class object.
[B]. A class object and a class.[C]. A class and a member of that class.
[D]. A class object and a member of that class.

Answer: Option D

Cpp Programming Quiz 139 – Which of the following two entities (reading from Left to Right) can be connected by the dot operator? Read More »

Cpp Programming, Objects And Classes