- 1、本文档共12页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
Abstract Classes Brookwood High Scool抽象类布鲁克伍德学校
Abstract Classes Mrs. C. Furman November 10, 2008 Abstract Classes Used when we have methods that will be overridden in every subclass. A superclass which represents an abstract concept and should NOT be instantiated. Abstract classes can have instance variables and concrete methods. public abstract class Shape { private String myName; public Shape (String name) { myName = name;} public String getName () { return myName;} //abstract methods public abstract double area(); public abstract double perimeter(); public double semiPerimeter () { return perimeter() / 2; } } Abstract Methods Methods which will be overridden in every subclass. They act as placeholders for Dynamic Binding. public class Circle extends Shape {private double myRadius; public Circle (double radius, String name) { super (name); myRadius = radius; } public double perimeter () { return 2 * Math.PI * myRadius;} public double area() { return Math.PI * Math.pow (myRadius,2);} } Shape a; a = new Shape (“blob”); //causes an error // we can not create abstract objects. a = new Circle (3, “circle”); Interface a collection of related methods whose headers are provided without implementation. All the methods are both public and abstract. A class that implements an interface must provide implementations for ALL methods declared in the interface. Additional methods can be implemented as well. If we do not override all the methods in the interface, we must be abstract. Interface vs. Abstract Interface can NOT provide implementation for any of its methods, abstract can. Interface can NOT contain instance variables, abstract can. Both interfaces and abstracts can declare constants. Interfaces can NOT be constructed. No instances of Abstract can be created. public interface PersonalInfo { String getName(); String getAddress(); int getSocialSecurityNo(); } //NO access specifiers. //They are all public abstract!! public class Student implements PersonalInfo { … } An
您可能关注的文档
- 2016年度精品插入鼻管程序 1.docx
- 2016年度精品操作系复习材料.docx
- 2016年度精品插针车间品质看20150715.docx
- 2016年度精品操作系解答题宝典.docx
- 2016年度精品本市视频安防监控系统用色显示终端技术规范.docx
- 2016年度精品标准四事务隔离级别.docx
- 2016年度精品步步心解读.docx
- 2016年度精品测用例优先级.docx
- 2016年度精品测量实室仪器设备操作规范流程.docx
- 2016年度精品语言编码300行,学生查询可运行.docx
- “双碳”目标下新能源汽车产业的国际贸易政策与支持措施研究.docx
- 2025年超星尔雅学习通《劳动通论》章节测试题库(名校卷) .pdf
- 人教版三年级数学下册第二单元综合测试卷含答案 .pdf
- 【《MMC-HVDC系统故障测距的故障类型识别(论文)》14000字】 .pdf
- 细胞内蛋白质运输与后修饰机制探究 .pdf
- 2025年超星尔雅学习通《劳动通论》章节测试题库(考试直接用) .pdf
- 2024-2025统编版道德与法治三年级下册半期考试卷附答案 .pdf
- 2025年上海浦东新区区高三二模高考英语试卷试题(含答案详解) .pdf
- 辽宁石化职业技术学院单招《职业技能测试》参考试题库(含答案) .pdf
- 2025届高考政治二轮复习《当代国际政治与经济》命题特点和备考策略探讨 .pdf
文档评论(0)