请教scjp中的问题

hejiehui 2001-11-30 10:41:39
有时候会有这样两种选项同时出现在供选择的答案中。比如一段代码:
class a{

}
...全文
111 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
hejiehui 2001-12-03
  • 打赏
  • 举报
回复
under what situation will the compiler exit before actually compile or what kind of error can be or can not be a compile time error.
hejiehui 2001-11-30
  • 打赏
  • 举报
回复
bsd is right.the answe is D.sorry for the mistake i made.but what's your mean about "does not compile"?isn't the scaning of the code a behaviour or part of of compile
bsd 2001-11-30
  • 打赏
  • 举报
回复
in JDK1.3
the answer may be D.
It does not compile.
ye_zhy 2001-11-30
  • 打赏
  • 举报
回复
而且用websphere是无法编译的
ye_zhy 2001-11-30
  • 打赏
  • 举报
回复
这样的程序会出现a未被初始化的错误
hexiaofeng 2001-11-30
  • 打赏
  • 举报
回复
觉得E 回答的更好
hejiehui 2001-11-30
  • 打赏
  • 举报
回复
sorry,let's continue:

class a{
public static void main(String[] args){
int a;
a=a+1;
}
}
question:what will happen when compile this code?
.
.
.
D does not compile
E complile but throw a compile time error

the answer is E.can sb tell me what the difference between choise D and E
cablink 2001-11-30
  • 打赏
  • 举报
回复
对于JAVA而言,局部变量在使用前一定要初始化,它没有缺省值,而是随机的。而实例变量有缺省值,可以不用
bsd 2001-11-30
  • 打赏
  • 举报
回复
I mean the compiler exit before it create a class file.
and the prompt is as following:
-----------
C:\src>javac testCompile.java
testCompile.java:4: 变量 a 可能还未被初始化
a=a+1;
^
1 个错误

C:\src>
------------

62,615

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧