- 1、本文档共49页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Dong Shao, Nanjing UnviersityA weird phenomenonDong Shao, Nanjing UnviersityWolf aWolf = new Wolf();Animal aHippo = new Hippo();It is weird:Animal anim = new Animal();Dong Shao, Nanjing UnviersityDong Shao, Nanjing UnviersityDong Shao, Nanjing UnviersityDong Shao, Nanjing UnviersityThe new hierarchyDong Shao, Nanjing UnviersityAbstract methodsDong Shao, Nanjing UnviersityNo Abstract Method in a Non-Abstract ClassDong Shao, Nanjing UnviersityImplement abstract methodsDong Shao, Nanjing UnviersityAbstract methods exist solely for polymorphism.A concrete class must implement all abstract methods.Implementing an abstract method is just like overriding a method.Building the Dog-specific listDong Shao, Nanjing UnviersityPolymorphismDong Shao, Nanjing UnviersityIf we need to keep Cats?Make a separate class MyCatList?Make an animal list to take any kind of animals.Dong Shao, Nanjing UnviersityDong Shao, Nanjing UnviersityWe don’t have a superclass for Animal?Every class in Java extends class Object, without you ever having to say it.You can think of it as though a class you write looks like:Public class Dog extends Object {}Dong Shao, Nanjing UnviersityDong Shao, Nanjing UnviersityDong Shao, Nanjing UnviersityDong Shao, Nanjing UnviersityDong Shao, Nanjing UnviersityDong Shao, Nanjing UnviersityDong Shao, Nanjing UnviersityDong Shao, Nanjing UnviersityDong Shao, Nanjing UnviersityDong Shao, Nanjing UnviersityThe compiler decides whether you can call a method based on the reference type, not the actual object type.The compiler checks the class of the reference type – not the object type – to see if you can call a method using that reference.The JVM decides which actual method is called based on the actual object type.Inner ObjectDong Shao, Nanjing UnviersityAn object contains everything it inherits from each of its superclasses. That means every object – regardless of its actual class type – is also an instance of class Object.Dong Shao, Nanjing UnviersityDong Shao, Nanjing
您可能关注的文档
- 名家翻译赏析-吉檀迦利.pptx
- 双子叶植物-芸香科2015广医上课.ppt
- HCDCE194 华为数据中心场景安装部署设计.pptx
- 一个研究案例分成租佃理论佃农概述.pptx
- 基本力系汇交力系的合成课件.ppt
- 智能楼宇监控系统简介幻灯片.ppt
- 第九讲 法的基本理论.ppt
- 单片机原理及接口技术3第3章 MCS-51的指令系统.ppt
- 无人机基础理论及应用概论.pptx
- 中国畜牧饲料产业互联网发展现状.pptx
- 报刊广告产业政府战略管理与区域发展战略研究咨询报告.docx
- 摄像头产业规划专项研究报告.docx
- 挖掘机市场发展分析及行业投资战略研究报告.docx
- 捕捞设备项目商业计划书(2024-2030).docx
- 抗生素行业兼并重组机会研究及决策咨询报告.docx
- 插秧机行业发展分析及投资价值研究咨询报告.docx
- 护手霜产业政府战略管理与区域发展战略研究报告.docx
- 干电池市场前景分析及投资策略与风险管理研究报告(2024-2030).docx
- 床上用品市场发展分析及行业投资战略研究报告(2024-2030).docx
- 整体橱柜市场前景分析及投资策略与风险管理研究报告(2024-2030).docx
文档评论(0)