SCJP -- static method can not access non-static variable?

binghuodao 2001-12-20 03:33:25
class TestServer {

final int users = 20;

public TestServer() {

int users = this.users * 10;

}

public static void main(String [] args){

System.out.println("Variable users = " + users);

}

}
A. Output is 200.

B. Output is 20.

C. The file will compile, but will give an error when run.

D. The file will not compile

答案是不是应选D?因为static方法不能访问non-static成员?
请讨论,谢谢!
...全文
154 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
binghuodao 2001-12-21
  • 打赏
  • 举报
回复
结了,给分
Patrick_DK 2001-12-20
  • 打赏
  • 举报
回复
楼上的,自己编译一下就知道了
binghuodao 2001-12-20
  • 打赏
  • 举报
回复
有没有不同意见?有没有人选B?
Patrick_DK 2001-12-20
  • 打赏
  • 举报
回复
D of course

这个问题还能怎么讨论啊?就是这样嘛
zych72 2001-12-20
  • 打赏
  • 举报
回复

62,634

社区成员

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

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