OOP and encapsulation - Quiz Explanation

The correct answers are indicated below, along with text that explains the correct answers.
 
1. The keyword private restricts the access of class or struct members to:
Please select the best answer.
  A. const functions
  B. static functions
  C. member functions
  D. clients
  The correct answer is C. The keyword public lets everyone have access to the members and private restricts access of the class or struct members to member functions.

2. What is the difference between an object and a class?
Please select the best answer.
  A. An object is an extension of the class construct whose default access privilege is public.
  B. The term object is just another way of referring to the public data members of a class.
  C. An object is an initialized class variable.
  D. A class is an initialized object variable.
  The correct answer is C.
An object is a class variable whose members have been initialized. For example, an object of the class student might have the value Clara Barton in the name data member. The other answers supplied are all erroneous in some way. A class is actually an extension of the struct concept whose default access is private.The default access privileges of a struct is public. An object is not just another way of referring to the public data members of a class.

3. If we have
class card {
public:
   int s;
};

card a;
card* p;

we can use _________ to access int s:
Please select the best answer.
  A. p.s
  B. a.s
  C. p -> int
  D. a -> s
  The correct answer is B.
The class member operator . is used as in class-variable. member-name.

4. In object-oriented software design, there is at least one extra step before you get to the coding of algorithms. That step is the design of:
Please select the best answer.
  A. classes that are appropriate for the problem at hand
  B. member functions
  C. program control flow
  D. the class's interface
  The correct answer is A. Designing member functions and the class's interface are actually parts of designing classes that are appropriate for the problem at hand. Designing program control is a software design step that is needed regardless of whether the program is being written in a procedural programming language or in an object-oriented programming language.

5. An interface in C++ is a
Please select the best answer.
  A. program that allows easy conversion of another program's data
  B. list of argument types in a function's parameter list
  C. library for performing input and output
  D. class's public members
  The correct answer is D.
In C++ (and most other OOP languages), the term interface refers to the public members of a class. A list of argument types in a function's parameter list is called a signature. The standard I/O library in C++ is iostream.

6. What is the difference between a struct and a class in C++?
Please select the best answer.
  A. A struct cannot have member functions.
  B. A class has a default privacy specification of public.
  C. A class has a default privacy specification of private.
  D. A struct cannot have private members.
  The correct answer is C.
The only difference between struct and class in C++ is that class has a default access specification of private and struct has a default access specification of public. Despite these default specifications, it will be our style in this course to prefer class to struct unless all members are data members with public access.It will also be our style to use access keywords explicitly.

7. An object is _____________ of a class.
Please select the best answer.
  A. an instance
  B. an interface
  C. an encapsulation
  D. a member function
  The correct answer is A.
An interface refers to the public members of a class.
Encapsulation is the packaging of an ADT's data and the functions that act on that data. An object can contain member functions if the class that the object is an instance of has member functions.