abstract抽象类
2016-06-07 08:30
357 查看
abstract class Computer{ abstract void open(); abstract void close(); void playGame(){ System.out.println("The WoW was loading..."); } } class WindowsComputer extends Computer{ public void open(){//抽象方法都是public,如果省略还是public,这一点不会改变。 System.out.println("The Windous was loading..."); } public void close(){ System.out.println("The Windows was loging off..."); } } class MacComputer extends Computer{ public void open(){ System.out.println("The Mac was loading..."); } public void close(){ System.out.println("The Mac was loging off..."); } } public class TestDemo{ public static void main(String args[]){ Computer pc = new WindowsComputer(); Computer airbook = new MacComputer(); pc.open(); airbook.open(); pc.close(); airbook.close(); pc.playGame(); airbook.playGame(); } } /*output The Windous was loading... The Mac was loading... The Windows was loging off... The Mac was loging off... The WoW was loading... The WoW was loading... */
相关文章推荐
- 设计引导--一个鸭子游戏引发的设计理念(多态,继承,抽象,接口,策略者模式)
- 解析abstract与override究竟可不可以同时使用
- c#中的interface abstract与virtual介绍
- PHP面向对象三大特点学习(充分理解抽象、封装、继承、多态)
- javascript 从if else 到 switch case 再到抽象
- Java final static abstract关键字概述
- 深入解读php中关于抽象(abstract)类和抽象方法的问题分析
- PHP abstract与interface之间的区别
- 深入解析C#中的abstract抽象类
- PHP 抽象方法与抽象类abstract关键字介绍及应用
- Java修饰符 abstract,static,final 的区别详解
- python抽象基类用法实例分析
- Java抽象类和抽象方法
- error C2259: 'CException' : cannot instantiate abstract class
- Java SE02 Java语言基础:关键字,标识符,注释
- C#覆写和重载
- 抽象思维:学习和思考的好方法
- java基础
- 对抽象类和虚方法的总结虚方法(virtual和abstract)
- java基础知识之——(static final abstract 三个修饰符)