大连理工大学:《Java语言程序设计》课程电子教案(讲稿)第二篇 面向对象程序设计 第6章 类的继承性

第6章类的继承性 理解类的继承性概念以及父类和子类的关糸 习 学习使用修饰符 protect、fnal、 abstract 理解多态性 具。使用甚口和内部类 标熟悉程序开发的过程和类的设计原则
第6章类的继承性 )理解类的继承性概念以及父类和子类的关系 )学习使用修饰符protect、final、abstract )理解多态性 )使用接口和内部类 )熟悉程序开发的过程和类的设计原则

61父类和子类 uperclass Circle Circle methods Circle data Inheritance Subclass Cylinder Circle methods Circle data Cylinder Methods Cylinder Data Superclass Subclass UML Diagram Circle CⅤ linder radius length getRadius setRadius findArea setlength find Volume
6.1 父类和子类 Superclass Circle Circle Methods Circle Data Inheritance Cylinder Circle Methods Cylinder Methods Circle Data Cylinder Data Subclass Circle -radius +getRadius +setRadius +findArea Cylinder -length +getLength +setLength +findVolume Superclass Subclass UML Diagram

Creating a Subclass Creating a subclass extends data and methods from the superclass. You can also e Add new data Add new methods Override the methods of the superclass Cylinder class
Creating a Subclass Creating a subclass extends data and methods from the superclass. You can also: ) Add new data ) Add new methods ) Override the methods of the superclass Cylinder Class

Example 6.1 Testing Inheritance Objective: Create a Cylinder object and explore the relationship between the ylinder and circle classes TestCylinder R un
Example 6.1 Testing Inheritance ) Objective: Create a Cylinder object and explore the relationship between the Cylinder and Circle classes. TestCylinder Run

6.2 The Object class The object class is the root of all Java classes c The tostring()method returns a string representation of the object The equals()method compares the contents of two objects The clone() method copy objects
6.2 The Object Class ) The Object class is the root of all Java classes. ) The toString() method returns a string representation of the object. ) The equals() method compares the contents of two objects. ) The clone() method copy objects

6.3修饰符 The protected Modifier g protected修饰符应用于类的数据和方法 上。公共类中保护的数据或方法可以被同 包中的任何类或它的子类访问,即使子 类在不同的包中也可以
6.3 修饰符 The protected Modifier ) protected 修饰符应用于类的数据和方法 上。公共类中保护的数据或方法可以被同 一包中的任何类或它的子类访问,即使子 类在不同的包中也可以

The protected Modifier pacakge pI acakge p2 C2是c1 class c class c2 extends C1 的子类 protected intx x can be read or modified in C2 C1和c3 在同 class C3 class C4 个包中 Cl cl CI c.x can be read or clx cannot be rea C4与c1 modified nor modified 不在同 个包 中
The protected Modifier pacakge p1 class C1 protected int x class C3 C1 c1; c1.x can be read or modified pacakge p2 class C2 extends C1 x can be read or modified in C2 class C4 C1 c1; c1.x cannot be read nor modified C1和C3 在同一 个包中 C2是C1 的子类 C4与C1 不在同 一个包 中

The final modifier The final class cannot be extended: final class Math The final variable is a constant. final static double pi 3.14159 The final method cannot be modified by its subclasses
The final Modifier ) The final class cannot be extended: final class Math {...} ) The final variable is a constant: final static double PI = 3.14159; ) The final method cannot be modified by its subclasses

The abstract modifier The abstract class Cannot be instantiated Should be extended and implemented in subclasses The abstract method Method signature without implementation
The abstract Modifier ) The abstract class – Cannot be instantiated – Should be extended and implemented in subclasses ) The abstract method – Method signature without implementation

64多态性和动态绑定 G多态性( polymorphism)是一个希腊 单词,意为多种形式。 a在Java中,可以在同一类或不同类中 定义名称相同但操作不同的多个方法, 多态性指的是运行时判断应该执行哪个 方法代码的能力。这种能力也叫做动态 绑定
6.4 多态性和动态绑定 )多态性(polymorphism)是一个希腊 单词,意为多种形式。 )在Java中,可以在同一类或不同类中 定义名称相同但操作不同的多个方法, 多态性指的是运行时判断应该执行哪个 方法代码的能力。这种能力也叫做动态 绑定
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 大连理工大学:《Java语言程序设计》课程电子教案(讲稿)第二篇 面向对象程序设计 第5章 使用对象和类编写程序.pdf
- 大连理工大学:《Java语言程序设计》课程电子教案(讲稿)第一篇 程序设计基础 第4章 方法.pdf
- 大连理工大学:《Java语言程序设计》课程电子教案(讲稿)第一篇 程序设计基础 第3章 控制语句.pdf
- 大连理工大学:《Java语言程序设计》课程电子教案(讲稿)第一篇 程序设计基础 第2章 基本数据类型和基本操作.pdf
- 大连理工大学:《Java语言程序设计》课程电子教案(讲稿)第一篇 程序设计基础 第1章 Java入门(主讲:赵铭伟).pdf
- 江西师大:《管理信息系统》第八章 面向对象的系统开发方法.ppt
- 江西师大:《管理信息系统》第七章 管理信息系统的系统实施.ppt
- 江西师大:《管理信息系统》第六章 管理信息系统的设计.ppt
- 江西师大:《管理信息系统》第五章 管理信息系统的系统分析.ppt
- 江西师大:《管理信息系统》第四章 MIS战略规划和开发方法.ppt
- 江西师大:《管理信息系统》第三章 管理信息系统的技术基础.ppt
- 江西师大:《管理信息系统》第二章 管理信息系统概论.ppt
- 《计算机图形学》课程教学资源:计算机图形学试卷(B)答案.doc
- 《计算机图形学》课程教学资源:计算机图形学试卷(B).doc
- 《计算机图形学》课程教学资源:计算机图形学(A)答案.doc
- 《计算机图形学》课程教学资源:计算机图形学(A).doc
- 《计算机图形学》课程教学资源:2003-2004计算机图形学试卷(B)答案.doc
- 《计算机图形学》课程教学资源:2003-2004计算机图形学试卷(B).doc
- 《数学与应用数学》2003-2004数学与应用数学试卷(A).doc
- 《计算机图形学》课程教学资源:2003-2004计算机图形学试卷(A).doc
- 大连理工大学:《Java语言程序设计》课程电子教案(讲稿)第二篇 面向对象程序设计 第7章 数组和向量.pdf
- 大连理工大学:《Java语言程序设计》课程电子教案(讲稿)第三篇 图形程序设计 第8章 图形程序设计入门.pdf
- 大连理工大学:《Java语言程序设计》课程电子教案(讲稿)第三篇 图形程序设计 第9章 创建用户界面.pdf
- 大连理工大学:《Java语言程序设计》课程电子教案(讲稿)第三篇 图形程序设计 第10章 applet和高级图形界面.pdf
- 浙江大学:《数据挖掘》课程电子教案(PPT教学课件)第六章 大型数据库中的关联规则挖掘.ppt
- 浙江大学:《数据挖掘》课程电子教案(PPT教学课件)第八章 聚类分析.ppt
- 浙江大学:《数据挖掘》课程电子教案(PPT教学课件)期末复习.ppt
- 浙江大学:《数据挖掘》课程电子教案(PPT教学课件)第九章 电子商务与数据挖掘.ppt
- 浙江大学:《数据挖掘》课程电子教案(PPT教学课件)第七章 分类和预测.ppt
- 浙江大学:《数据挖掘》课程电子教案(PPT教学课件)第一章 序论(主讲教师:王灿).ppt
- 浙江大学:《数据挖掘》课程电子教案(PPT教学课件)第二章 数据仓库和数据挖掘的OLAP技术.ppt
- 浙江大学:《数据挖掘》课程电子教案(PPT教学课件)第三章 数据预处理.ppt
- 浙江大学:《数据挖掘》课程电子教案(PPT教学课件)第四章 数据挖掘原语、语言和系统结构.ppt
- 浙江大学:《数据挖掘》课程电子教案(PPT教学课件)第五章 概念描述:特征化与比较.ppt
- 《网页制作宝典》第1章 网页制作初识.ppt
- 《网页制作宝典》第10章 JavaScriptDHTML和技术.ppt
- 《网页制作宝典》第11章 示例网页利用ASP实现交互功能.ppt
- 《网页制作宝典》第12章 利用ADO实现网页与数据库的链接.ppt
- 《网页制作宝典》第2章 创建站点.ppt
- 《网页制作宝典》第3章 网页文本的处理.ppt