course05-对象和类2.pptVIP

  • 2
  • 0
  • 约1.81千字
  • 约 42页
  • 2017-04-24 发布于江西
  • 举报
course05-对象和类2.ppt

JAVA语言程序设计;第七讲 对象和类(续);类的继承;类的继承;类的继承;继承中的super对象;3. 父类对象与子类对象的转换;SuperClass sc=new SubClass();;继承中的构造方法;再谈继承中的构造方法;再谈继承中的构造方法;类的继承;类的继承;类的继承;类的继承;类的继承;类的继承;继承中类对象作为参数传递;Subclasses inherit those superclass members declared as public or protected. Subclasses inherit those superclass members declared with no access specifier as long as the subclass is in the same package as the superclass. Subclasses dont inherit a superclasss member if the subclass declares a member with the same name. In the case of member variables, the member variable in the subclass hides the one in the superclass. In the case of methods, the method in the subclass overrides the one in the superclass.;小结;类的继承;继承与组合;一个文件中定义多个JAVA类;第七讲 对象和类(续);抽象类(abstract class);抽象类(abstract class);抽象类(abstract class);抽象类(abstract class);第七讲 对象和类(续);static变量的初始化;设计模式的例子;“Design Patterns: Elements of Reusable Object-Oriented Software” (设计模式) Erich Gamma、Richard Helm、Ralph Johnson、John Vlissides Addison-Wesley, 1995 这几位作者常被称为“四人组(Gang of Four)”, 而这本书也就被称为“四人组(或 GoF)”书 设计模式: 在一定的环境中解决某一问题的方案 23 种设计模式, 3大类 创建型模式(Creational pattern)规定了创建对象的方式,如Singleton模式、Factory Method模式 结构型模式(Structural pattern)规定了如何组织类和对象。这些模式涉及类如何相互继承或如何从其它类组合,如Adapter、Proxy 和 Decorator 模式 行为模式(Behavioral pattern)规定了对象之间交互的方式。如Observer模式、Strategy和Template 模式 并发模式(Concurrency pattern)规定协调或顺序对共享资源访问的方式 MVC(Model/View/Controller, 模型/视图/控制器);设计模式的例子;第七讲 对象和类(续);接口是对abstract类的进一步扩展 接口中的方法都是未实现的(类似于抽象方法),目的是在实现接口的类之间建立一种协议 接口中的变量都是常量 定义 一个类符合某个或一组接口,利用implements;接口名修饰 public: 无任何访问限制 无修饰: 仅限于本包中 接???变量默认都是“public static final” public interface Months { int JANUARY=1, FEBRUARY=2, MARCH=3, APRIL=4, MAY=5, JUNE=6, JULY=7, AUGUST=8, SEPTEMBER=9,OCTOBER=10, NOVEMBER=11,DECEMBER=12; };接口 (interface);接口 (interface);接口 (interface);接口 (interface);接口 (interface); 第七讲 结束 !

文档评论(0)

1亿VIP精品文档

相关文档