资源描述:
《Chapter 9 Inheritance and Polymorphism》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、Chapter9InheritanceandPolymorphismChapter6ArraysChapter7ObjectsandClassesChapter8StringsandTextI/OGUIcanbecoveredafter§10.2,“AbstractClasses”Chapter9InheritanceandPolymorphismChapter12GUIBasics§10.2,“AbstractClasses”Chapter13Graphics§10.4,“Interfaces”Chapt
2、er14Event-DrivenProgrammingChapter11Object-OrientedDesignExceptionandbinaryI/OcanbecoveredafterChapter9Chapter17ExceptionsandAssertionsChapter18BinaryI/OLiang,IntroductiontoJavaProgramming,SixthEdition,(c)2007PearsonEducation,Inc.All1rightsreserved.0-13-22
3、2158-6ObjectivesuTodevelopasubclassfromasuperclassthroughinheritance(§9.2).uToinvokethesuperclass’sconstructorsandmethodsusingthesuperkeyword(§9.3).uTooverridemethodsinthesubclass(§9.4).uTodistinguishdifferencesbetweenoverridingandoverloading(§9.5).uToexpl
4、oretheusefulmethods(equals(Object),hashCode(),toString(),finalize(),clone(),andgetClass())intheObjectclass(§9.6,§9.13optional).uTocomprehendpolymorphism,dynamicbinding,andgenericprogramming(§9.7).uTodescribecastingandexplainwhyexplicitdowncastingisnecessar
5、y(§9.8).uTostore,retrieve,andmanipulatesobjectsinanArrayList(§9.9).uToimplementaStackclassusingArrayList(§9.10).uTorestrictaccesstodataandmethodsusingtheprotectedvisibilitymodifier(§9.11).uTodeclareconstants,unmodifiablemethods,andnonextendableclassesusing
6、thefinalmodifier(§9.12).u(Optional)Tounderstandtheeffectofhidingdatafieldsandstaticmethods(§9.14).u(Optional)Toinitializedatausinginitializationblocksandtodistinguishbetweeninstanceinitializationandstaticinitializationblocks(§9.15).u(OptionalGUI)Touseinher
7、itanceinGUIprogramming(§9.16).Liang,IntroductiontoJavaProgramming,SixthEdition,(c)2007PearsonEducation,Inc.All2rightsreserved.0-13-222158-6SuperclassesandSubclassesGeometricObject-color:StringThecoloroftheobject(default:white).-filled:booleanIndicateswheth
8、ertheobjectisfilledwithacolor(default:false).-dateCreated:java.util.DateThedatewhentheobjectwascreated.+GeometricObject()CreatesaGeometricObject.+getColor():StringReturnsthecolor.+setColor(color:String):voidS