java中抽象类和抽象方法到底什么关系?请举例说明!
来源:互联网 发布:淘宝网访问验证 编辑:程序博客网 时间:2024/04/30 20:10
抽象类和抽象方法什么关系?抽象类中可能有抽象方法,也可能没有抽象方法。那位说,就跟没说一样,那抽象类和抽象方法都叫抽象,他们必定有关系,那关系是什么呢?如果一个类中有抽象方法,它必须得是抽象类。
An abstract class may have no abstract method,such as the following class Car. 马 克- t o --wi n: At this time,the only point and the meaning of abstract class is that we can not instantiated the class, because it is abstract class.Why an abstract class can have a nonabstract method? what is the point? also in logic, think over the following example, car is a bit abstract in that you dont' know exactly whether it is a truck or a jeep or a limersine, 马克-to-win:so it is defined as a abstract class. but no matter whether it is truck,jep, or limersine, it definitely use steering wheel. so its steer() method is an ordinary method instead of an abstract method. ) Abstract class can’t be instantiated.
例1.7.1
abstract class Nothing {//里面有方法也照样声明为abstract
void nothing() {
System.out.println("nothing");
}
}
abstract class VehMark_to_win {
abstract void steer();
abstract void move();
}
class Bike extends VehMark_to_win {//Bike不是抽象的, 所以必须得全部实现abstract方法
。。。。。。。。。。。。。。。
详情请见:http://www.mark-to-win.com/JavaBeginner/JavaBeginner3_web.html#RelationAbstractMethodClass
An abstract class may have no abstract method,such as the following class Car. 马 克- t o --wi n: At this time,the only point and the meaning of abstract class is that we can not instantiated the class, because it is abstract class.Why an abstract class can have a nonabstract method? what is the point? also in logic, think over the following example, car is a bit abstract in that you dont' know exactly whether it is a truck or a jeep or a limersine, 马克-to-win:so it is defined as a abstract class. but no matter whether it is truck,jep, or limersine, it definitely use steering wheel. so its steer() method is an ordinary method instead of an abstract method. ) Abstract class can’t be instantiated.
例1.7.1
abstract class Nothing {//里面有方法也照样声明为abstract
void nothing() {
System.out.println("nothing");
}
}
abstract class VehMark_to_win {
abstract void steer();
abstract void move();
}
class Bike extends VehMark_to_win {//Bike不是抽象的, 所以必须得全部实现abstract方法
。。。。。。。。。。。。。。。
详情请见:http://www.mark-to-win.com/JavaBeginner/JavaBeginner3_web.html#RelationAbstractMethodClass
0 0
- java中抽象类和抽象方法到底什么关系?请举例说明!
- java中抽象类和抽象方法到底有什么用呢?
- java抽象类和抽象方法之间的关系
- java中的抽象函数是什么? 和抽象类是什么关系? 抽象类是什么?又什么作用?
- java中什么叫抽象方法和抽象类及他们的特点
- 关于Java抽象类和接口的区别与举例说明
- 谈《Java中抽象类,抽象方法,重载和覆盖》
- java中抽象方法和抽象类实现模版模式
- Java中抽象类和抽象方法的区别
- Java中抽象类和抽象方法的区别
- Java中抽象类和抽象方法的区别 ---------------
- java抽象类和抽象方法
- java抽象类和抽象方法
- java抽象类和抽象方法
- Java抽象类和抽象方法
- java中的抽象类和抽象方法
- java的抽象类和抽象方法
- java抽象类和抽象方法
- 两个线程A和B,任务都是打印当前时间,要求编码实现:线程A和B同时启动后,以先A后B的方式任务交叉执行10次。
- UVa 400题记录
- 使用HTML5构建iOS原生APP(2)
- java中ServletContext 对象的获取方法
- BootStrap2.x中的时间选择控件
- java中抽象类和抽象方法到底什么关系?请举例说明!
- JavaScript实现超大字符串运算减法
- Linux内核开发:使用 Git 管理源代码
- C#预编译指令
- Android消息处理机制(好文)
- DRBD部署
- java是传值的方式
- zookeeper使用和原理探究(一)
- DOM4j读取XML文件(SAXReader)