每日一讲多态.pptxVIP

  • 13
  • 0
  • 约1.59千字
  • 约 10页
  • 2016-12-07 发布于湖北
  • 举报
Java: 多态多态别称Dynamic Binding 动态绑定Late Binding 迟绑定Polymorphism 多态 多态性 多态定义动态绑定:指程序在执行期间(而非编译期)判断所引用对象的实际类型,根据其实际的类型调用其相对应的方法。静态绑定:指程序在编译期间就决定调用哪个方法,一般指方法的重载。多态示例class Dog extends Animal{ private StringfurColor ; Dog (String n, String c){ super ( n ); furColor = c; } public void enjoy ( ) { System.out.println(“狗叫声…”); }}/*class Birdextends Animal{ Bird ( ){ super (“bird”); } public void enjoy ( ) { System.out.println(“鸟叫声…”); }}*/classAnimal{ private String name; Animal (String name) { this.name = name; } public void enjoy ( )

文档评论(0)

1亿VIP精品文档

相关文档