没有实现抽象方法的具体类居然编译通过了

来自csdn:

http://topic.csdn.net/u/20110131/09/7099a295-3877-4b2d-81bd-46137e5530c9.html

 

package pack1;

public abstract class A {
	abstract void set();
}

 

package pack2;

import pack1.A;

public abstract class B extends A {
	protected void set() {
	}
}

 

package pack1;

import pack2.B;

public class C extends B {
	public static void main(String[] args) {
		A the = new C();
		the.set();
	}
}

 

let's have a try, if you compile it, you'll find no error occurs at compile time, why? as B does not override A, but the compilation passed, according to the java doc:

 

public class AbstractMethodError

extends IncompatibleClassChangeError

Thrown when an application tries to call an abstract method. Normally, this error is caught by the compiler; this error can only occur at run time if the definition of some class has incompatibly changed since the currently executing method was last compiled.

 

no changes have been made, it still passes, is it the bug of the javac? let's check it out.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值