第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