COP 3330 - TEST 1 COMPREHENSIVE REVIEW Questions with Correct
Solutions
Question:
1. Machine language
Answer:
The language the computer actually needs; hard for people to read.
Question:
2. Assembly language
Answer:
Symbolic translations of machine code; easier for people to read than raw machine code.
Question:
3. Object-oriented language
Answer:
Languages like C++, Java, Smalltalk. They encapsulate data and procedures together in units
called objects, making items modular as well.
Question:
4. C++
Answer:
An OBJECT-ORIENTED programming language based on C
Question:
5. Object
Answer:
An encapsulation of data and functions that act upon that data.
Question:
6. The three aspects of an object
Answer:
Name, Attributes (member data), and Behavior (member functions).
Question:
7. What is member data?
Answer:
The data that describes what the object is
,Question:
8. what are member functions?
Answer:
Functions that describe what the object does.
Question:
9. What is a Class?
Answer:
A blueprint for objects
Question:
10. What does a class description consist of
Answer:
A declaration and a definition that are in different files
Question:
11. Instance
Answer:
An object is a single instance of a class. Many objects can be created from the same class, like
many houses from one blueprint.
Question:
12. struct (in C)
Answer:
only has a Name and Attributes. No functions bundled in.
Question:
13. Key difference: C vs C++ data and functions
Answer:
C: data and functions are separate C++: you can build objects that encapsulate data and
functions
Question:
14. DDU Design
Answer:
Declare, Define, Use.
,Question:
15. Declare (in DDU)
Answer:
A declaration gives an interface. Shows what an object will look like and what functions are
available, without implementation details.
Question:
16. Define (in DDU)
Answer:
The implementation details. A function definition is the code that makes a function work (the
function body).
Question:
17. Use (in DDU)
Answer:
The use of an item through its interface. The user of a class is a programmer, who creates
objects and calls the available functions.
Question:
18. Interface
Answer:
What the user sees
Question:
19. what is the public portion of a class?
Answer:
Can be accessed from inside or outside of the object.
Question:
20. what is the private portion of a class?
Answer:
Can only be used by the object itself.
Question:
21. Which section of a class is the interface?
Answer:
The public section.
, Question:
22. Standard practice for member data
Answer:
Protect it by making it private
Question:
23. Four reasons for data hiding
Answer:
1) Makes the interface simpler for the user.
2) Principle of least privilege
3) More secure, less chance of misuse, accidental or malicious.
4) Class implementation is easy to change without affecting other modules that use it.
Question:
24. Class declaration format
Answer:
class <className> { public: (public members) private: (private members) };.
Question:
25. Goal of good class design
Answer:
Guarantee that an object is ALWAYS in a valid semantic state, regardless of what features the
user calls upon.
Question:
26. What is an invalid semantic state?
Answer:
A combination of an object's data values that violates the rules or meaning of the class
Question:
27. What goes in the public section?
Answer:
Only the members the user needs to call upon directly.
Question:
28. What goes in the private section?
Answer:
Things the user does not need to use directly. Typically most of the member data.
Solutions
Question:
1. Machine language
Answer:
The language the computer actually needs; hard for people to read.
Question:
2. Assembly language
Answer:
Symbolic translations of machine code; easier for people to read than raw machine code.
Question:
3. Object-oriented language
Answer:
Languages like C++, Java, Smalltalk. They encapsulate data and procedures together in units
called objects, making items modular as well.
Question:
4. C++
Answer:
An OBJECT-ORIENTED programming language based on C
Question:
5. Object
Answer:
An encapsulation of data and functions that act upon that data.
Question:
6. The three aspects of an object
Answer:
Name, Attributes (member data), and Behavior (member functions).
Question:
7. What is member data?
Answer:
The data that describes what the object is
,Question:
8. what are member functions?
Answer:
Functions that describe what the object does.
Question:
9. What is a Class?
Answer:
A blueprint for objects
Question:
10. What does a class description consist of
Answer:
A declaration and a definition that are in different files
Question:
11. Instance
Answer:
An object is a single instance of a class. Many objects can be created from the same class, like
many houses from one blueprint.
Question:
12. struct (in C)
Answer:
only has a Name and Attributes. No functions bundled in.
Question:
13. Key difference: C vs C++ data and functions
Answer:
C: data and functions are separate C++: you can build objects that encapsulate data and
functions
Question:
14. DDU Design
Answer:
Declare, Define, Use.
,Question:
15. Declare (in DDU)
Answer:
A declaration gives an interface. Shows what an object will look like and what functions are
available, without implementation details.
Question:
16. Define (in DDU)
Answer:
The implementation details. A function definition is the code that makes a function work (the
function body).
Question:
17. Use (in DDU)
Answer:
The use of an item through its interface. The user of a class is a programmer, who creates
objects and calls the available functions.
Question:
18. Interface
Answer:
What the user sees
Question:
19. what is the public portion of a class?
Answer:
Can be accessed from inside or outside of the object.
Question:
20. what is the private portion of a class?
Answer:
Can only be used by the object itself.
Question:
21. Which section of a class is the interface?
Answer:
The public section.
, Question:
22. Standard practice for member data
Answer:
Protect it by making it private
Question:
23. Four reasons for data hiding
Answer:
1) Makes the interface simpler for the user.
2) Principle of least privilege
3) More secure, less chance of misuse, accidental or malicious.
4) Class implementation is easy to change without affecting other modules that use it.
Question:
24. Class declaration format
Answer:
class <className> { public: (public members) private: (private members) };.
Question:
25. Goal of good class design
Answer:
Guarantee that an object is ALWAYS in a valid semantic state, regardless of what features the
user calls upon.
Question:
26. What is an invalid semantic state?
Answer:
A combination of an object's data values that violates the rules or meaning of the class
Question:
27. What goes in the public section?
Answer:
Only the members the user needs to call upon directly.
Question:
28. What goes in the private section?
Answer:
Things the user does not need to use directly. Typically most of the member data.