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中,可以在同一类或不同类中 定义名称相同但操作不同的多个方法, 多态性指的是运行时判断应该执行哪个 方法代码的能力。这种能力也叫做动态 绑定