CPSC 2150 - DAY 23 DECEMBER 1, 2016 ================================================================================ NESTED INTERFACES ----------------- .An interface may be nested within another interface. STATIC NESTED CLASS ------------------- .A Static nested class does not have access to instance members of its enclosing class. .Effectively, its a top-level class declared inside another class since it logically belongs THE MANY MEANINGS OF FINAL -------------------------- .A class declared final may not be extended .A method declared final may not be overridden .A variable declared final may not be modified once it is given a value -------------------------------------------------------------------------------- FINAL EXAM REVIEW -------------------------------------------------------------------------------- .Software engineering question .Design pattern question .Specification/test plan question .Tracing/reasoning question .Java Code quetion SOFTWARE ENGINEERING QUESTION ----------------------------- .When using design-by-contract, explain the responsibilites of users and implementers. .Explain the principle of information hiding. .Explain why information hiding alone is not sufficient and abstraction is needed in interface specification. .Constrast the use of requires clauses and exceptions. DESIGN PATTERN QUESTION ----------------------- .Explain the essence of the template method design pattern with an example or otherwise. .Explain the essence of the observer pattern with an example or otherwise. .Explain the essence of the factory method with an example or otherwise. .Explain the essence of the decorator pattern with an example or otherwise. SPECIFICATION/TEST PLAN QUESTION -------------------------------- .The specification of an operation is given below. Develop a test plan with 3 test points. .Be sure to review string theory notations. /* updates this, q; * requires |this| < maxLength and 0 < |q|; * ensures this = #this o Prt_Btwn(0, 1, #q) * and q = Prt_Btwn(1, |#q|, q); */ void mysteryOp(IntegerQueue q); TRACING/REASONING QUESTION -------------------------- .What does this code do to integers i and j? .Assume that the initial values of i is #i and the initial value of j is #j. .Express the answers in terms of #i and #j i = i + 17; j = i; i = i - j; JAVA CODE QUESTION ------------------ .Write a method to search an integer array (or array list) for a given item. .Explain why you should override the equals method when you write a new class with an example or otherwise. .Using an interface I and classes C and D that implements that interface, create objects and write code to show your understanding of polymorphism .Give an example of a good use of an abstract class.