C++ Programming - C++ Classes And Objects Multiple Choice Questions and Answers

Related Topics:

C++ Programming : C++ Classes And Objects

Following questions depends on the c++ classes and objects. Each questions has its unique answer.
1. Which of the following is false?
[A] Variable has scope & visibility
[B] Variables having scope may not be visible
[C] Variables having visibility may not have scope
[D] None of these

Answer: C. Variables having visibility may not have scope

2. For a method to be an interface between the outside world and a class,it has to be declared ?
[A] private
[B] protected
[C] public
[D] external

Answer: C. public

3. In C++, a function contained within the class is called ?
[A] member function
[B] a class function
[C] a method
[D] none of above

Answer: A. member function

4. classes are useful because they
[A] are removed from memory when not in use
[B] permit data to be hidden from other classes
[C] bring together all aspects of an entity in one place
[D] can closely model objects in the real world

Answer: B. permit data to be hidden from other classes

5. The public files in a class library usually contain ?
[A] Constant definitions
[B] member function definitions
[C] class declarations
[D] variable definition

Answer: C. class declarations

6. A class cannot be ?
[A] Virtual
[B] Generic
[C] Inline
[D] Friend

Answer: C. Inline

Explanation:

A Class cannot be a Inline.
7. Objects of the same class share the values of ...... while they maintain separate values for ........ .
[A] Static variables, non static variables
[B] Non static variables, static variables
[C] Global variables, static variables
[D] Static variables, register variables

Answer: A. Static variables, non static variables

Explanation:

Objects of the same class share the values of Static variables while they maintain separate values for non static variables.
8. Which of the following keywords cannot appear inside a class definition ?
[A] friend
[B] static
[C] template
[D] virtual

Answer: C. template

Explanation:

A Template keyword cannot appear inside a class function.
9. Shallow copy is
[A] Member wise copying of objects
[B] A substitute for the operator
[C] Same kind like deep copy
[D] Used in constructor

Answer: A. Member wise copying of objects

10. Which member function of class cannot modify its objects attributes ?
[A] friend functions
[B] Private member functions
[C] Constant member functions
[D] Static member functions

Answer: C. Constant member functions


Comments: (Your feedback is valuable to us)

rohit 2 weeks ago Reply

helpful thank you so much


arbab 11 months ago Reply

was helpful


;