Exam 1 CS3358 YUP.pdf
Document Details
Uploaded by TriumphalChrysoprase8230
H. Councill Trenholm State Community College
Tags
Related
- Object-Oriented Programming, Lecture 06 PDF
- Object Oriented Programming With C++ (Fifth Edition) PDF
- An Introduction to Programming Through C++ Lecture 24 Revision PDF
- 22316 Object-Oriented Programming using C++ Sample Question Paper PDF
- Object-Oriented Programming in C++ (Level 2) PDF
- C++ Object-Oriented Programming Concepts PDF
Full Transcript
Question 1. C++ Both the separation of a component’s interface from the components implementation (by allowing them to be placed in different files ) and separate compilation of the component (by allowing the component to be compiled in isolation) in order to facilitate information hiding and modula...
Question 1. C++ Both the separation of a component’s interface from the components implementation (by allowing them to be placed in different files ) and separate compilation of the component (by allowing the component to be compiled in isolation) in order to facilitate information hiding and modular programming. In the list below, circle the two most important benefits of information hiding and modular programming (Hint: must be those indicated/discussed in class.) A. Usability B. Reusability C. Portability D. Maintainability E. Reliability F. Scalability Question 2: Fill each box in the following diagram (that depicts some logical associations related to object-based data type development using C++ and contract-oriented approach) discussed in class with a number indicating the best matching entry on the company boxed list. Each number should only appear once. One box is already filled in for you. 1. Assume not valid on entry, guarantee (begins to be) valid on exit. 2. Expect “fullfilled” 3. Expect “valid” (check “if valid” where possible) 4. Expect valid on entry, dont care (if still valid) on exit. 5. Expect valid on entry, maintain remains valid on exit 6. Gurantee “fullfilled” 7. Expect “valid” on entry, dont care (if “still valid”) on exit Client (Pre-condition)? 7. Expect “valid” on entry, dont care (if “still valid”) on exit Client (Post-condition)? 2. Expect “fulfilled” Developer (Pre-condition)? 3. Expect “valid” (check “if valid” where possible) Developer (Postcondition)? 6.guarantee “fulfilled” Constructors (class invariant)? 1. Assume not valid on entry, guarantee (begins to be) valid on exit. Destructors(class invariant)? 4. Expect valid on entry, dont care (if still valid) on exit. The rest(class invariant)? 5. Expect valid on entry, maintain remains valid on exit Question 3. Which of the following best describes how abstraction is useful to us in problem solving? (Check only one.) A. It promotes the use of pseudocode and thus frees us from language-dependent details B. It promotes the use of top down (not bottom-up) approach C. It promotes the use of top-down (not bottom-up) approach D. It helps us in managing the complexities of the problem E. It enables us to never have to deal with the complexities of the problem Question 4. Which of the following best characterizes an ADT (Abstract Data Type)? A. It specifies what it is, not how it is to be implemented B. It specifies what it is and how it is to be implemented C. It specifies what it is and how it is to be implemented, not the language that is to be used D. It specifies what it is in a header file and how it is to be implemented in an implementation file. Question 5a. Big + Yes? A. Pass x by value B. Pass x by reference C. Pass x by const reference Question 5b. Big + No? D. Pass x by value E. Pass x by reference F. Pass x by const reference Question 5c. Small + Yes? G. Pass x by value H. Pass x by reference I. Pass x by const reference Question 5d. Small + No? J. Pass x by value K. Pass x by reference L. Pass x by const reference Question 6. A member function of a class ____? A. Can directly access the private data members of all objects of the class visible to the function B. Cannot directly access the private data members of only the invoking object C. Cannot directly access the private data members of an object of the class that is passed to the function by const reference D. Can directly access the private data members of all objects of the class visible to the function except the invoking object Question 7a. Avoid breaking encapsulation? A. Including using namespace std, in header file? B. Unnecessarily passing parameter by reference C. Inappropriately using friend function D. Inappropriately exposing implementation detail Question 7b. Don't baffle the client E. Including using namespace std, in header file? F. Unnecessarily passing parameter by reference G. Inappropriately using friend function H. Inappropriately exposing implementation detail Question 7c. Don't make soup too salty I. Including using namespace std, in header file? J. Unnecessarily passing parameter by reference K. Inappropriately using friend function L. Inappropriately exposing implementation detail Question 7d. Least privilege M. Including using namespace std, in header file? N. Unnecessarily passing parameter by reference O. Inappropriately using friend function P. Inappropriately exposing implementation detail Question 8. Which of the following techniques best describes templating? A. Specialization B. Parameterization C. Modularization D. Encapsulation Question 9. What restrictions are placed on the Item data type for a program that uses the isSmaller function? Template Bool isSmaller(Item a, Item b) { return a