Docsity

Object-Oriented Design and Patterns - Practice Questions | CSI 3471, Study notes of Software Engineering

Toggle sidebar
bg1
Object‐OrientedDesign&Patterns
Chapter6Questions
Revised10/31/2008
1. InheritanceandMultipleInheritance
a. Whatismultipleinheritance?
b. Whatpotentialproblemsdoesmultipleinheritancecreate?(pp.246f)
c. WhenshouldInoteuseinheritance?(pp.254f)
2. TheSubstitutionPrinciple
a. Statethesubstitutionprincipleandgivenanexampleofitsuse.
b. Whatproblemdoesthisprincipleattempttoavoid?
3. Pre‐conditionsandPostconditionswithInheritance
a. WhatmustIavoidwhendefiningapreconditionforasubclass?
b. WhatmustIavoidwhendefiningapostconditionforasubclass?
4. GraphicsProgrammingwithInheritance
a. Whatarethetwolistenerinterfacesforamouseevent?
b. Whyaretheretwolistenerinterfacesforamouseevent
c. Whatisthepurposeofthetwomouseadapterclasses?
d. UnderstandtheCar/Component/Moverexample.Youcanfindthecodeat
//ProfData/Grabow/csi3471/Workspace/car
5. AbstractClasses
a. Canyouconstructanobjectbasedonanabstractclass?
b. WhatisthebenefitofusingtheSelectableShapeabstractclassinthesceneexample?
c. Explainthesceneexampleusingtheclassdiagramonp.230.
d. Isitlegaltotaganyclassasabstract,evenifallofitsmethodsarealreadydefined?
Shouldyoudothis?
e. Canaclassextendmorethanoneabstractclass?Canaclassimplementmorethanone
interface?
f. CompareclassCarComponent(pp.226f)andclassSceneComponent(pp.232f)with
respecttotheirattributes.Whyisthereadifference?
g. WhatisthedefaultlayoutusedtocreatethebuttonsJPanelonp.234?
h. Executethescene3example(itslocationisthesameasthecarexamplementioned
above).WhatcodeexecuteswhenyouhittheRemovebuttonandthereisnothingto
remove?
6. TheTemplateMethodPattern
a. Whatproblemdoesthispatternaddress?
b. Describethenatureofthissolutionusingtheclassdiagramonp.237.
c. Howdoesscene2usethetemplatemethodpattern?
d. WhyandhowisCarShapeinthescene2exampledifferentfromCarShapeinthescene1
example?
7. ProtectedInterfaces
a. Whatisaprotectedinterface?
b. Howdoesscene3implementaprotectedinterface?
8. Later
a. TheHierarchyofSwingComponents
b. TheHierarchyofStandardGeometricShapes
c. heHierarchyofExceptionClasses

Partial preview of the text

Download Object-Oriented Design and Patterns - Practice Questions | CSI 3471 and more Study notes Software Engineering in PDF only on Docsity!

Object‐Oriented Design & Patterns Chapter 6 Questions Revised 10/31/

  1. Inheritance and Multiple Inheritance a. What is multiple inheritance? b. What potential problems does multiple inheritance create? (pp. 246f) c. When should I note use inheritance? (pp. 254f)
  2. The Substitution Principle a. State the substitution principle and given an example of its use. b. What problem does this principle attempt to avoid?
  3. Pre‐conditions and Post conditions with Inheritance a. What must I avoid when defining a precondition for a subclass? b. What must I avoid when defining a post condition for a subclass?
  4. Graphics Programming with Inheritance a. What are the two listener interfaces for a mouse event? b. Why are there two listener interfaces for a mouse event c. What is the purpose of the two mouse adapter classes? d. Understand the Car/Component/Mover example. You can find the code at //ProfData/Grabow/csi3471/Workspace/car
  5. Abstract Classes a. Can you construct an object based on an abstract class? b. What is the benefit of using the SelectableShape abstract class in the scene example? c. Explain the scene example using the class diagram on p. 230. d. Is it legal to tag any class as abstract, even if all of its methods are already defined? Should you do this? e. Can a class extend more than one abstract class? Can a class implement more than one interface? f. Compare class CarComponent (pp. 226f) and class SceneComponent (pp. 232f) with respect to their attributes. Why is there a difference? g. What is the default layout used to create the buttons JPanel on p. 234? h. Execute the scene3 example (its location is the same as the car example mentioned above). What code executes when you hit the Remove button and there is nothing to remove?
  6. The Template Method Pattern a. What problem does this pattern address? b. Describe the nature of this solution using the class diagram on p. 237. c. How does scene2 use the template method pattern? d. Why and how is CarShape in the scene2 example different from CarShape in the scene example?
  7. Protected Interfaces a. What is a protected interface? b. How does scene3 implement a protected interface?
  8. Later a. The Hierarchy of Swing Components b. The Hierarchy of Standard Geometric Shapes c. he Hierarchy of Exception Classes