CPSC 2150 - Exam 1 || with 100% Error-free Solutions.
What is encapsulation? correct answers grouping related data and operations together What is information hiding? correct answers how we control access to encapsulated data and operations How do we hide information? correct answers using visibility settings (public, private, package private, protected) What does a good design help with? correct answers code reuse, debugging, and the ability to adapt to change What are the two roles in a contract? correct answers the implementer and the client What does a precondition define? correct answers the client's responsibility What question do you ask while dealing with preconditions? correct answers What would cause the code to fail? What does a postcondition define? correct answers the implementer's responsibility What question do you ask while dealing with postconditions? correct answers What will be true after the code is finished? What are the implementer's responsibilities? correct answers responsible for postcondition, they assume the precondition is true What are the client's responsibilities? correct answers responsible for preconditions, they assume the postcondition's will be true What does the contract show about a method? correct answers parameter names, method name/return value, class variable names. it does this in mathematical notation True or False: invariants are sometimes true and are always enforced correct answers false; invariants are always true and must always be enforced What do invariants refer to about the class? correct answers some property of a variable in a class At what points in the program should the invariant be true? correct answers after the constructor has been called, before any public methods are invoked, after any public methods have finished At what points in the program should the invariant be false? correct answers during the execution of a method, before the call of a private method, after the call of a private method Who is ultimately responsible for invariants? correct answers the implementer of the class defines the invariant and the implementer of any public class method is responsible for making sure that the invariant is always held to be true
Written for
- Institution
- CPSC 2150
- Course
- CPSC 2150
Document information
- Uploaded on
- March 25, 2024
- Number of pages
- 4
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
Also available in package deal