首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
阅读下面的程序: public class Person{ int arr[ ]=Hew int[10]; public static void main(String args[ ]){
阅读下面的程序: public class Person{ int arr[ ]=Hew int[10]; public static void main(String args[ ]){
admin
2010-12-17
37
问题
阅读下面的程序: public class Person{ int arr[ ]=Hew int[10]; public static void main(String args[ ]){ System.out.println(arr[1]); } } 正确的说法是______。
选项
A、编译时将产生错误
B、编译时正确,运行时将产生错误
C、输出为0
D、输出为空
答案
A
解析
由于数组arr声明时未使用static关键字,而main( )方法直接引用arr(而非通过 Person的实例引用),将产生“非静态变量不能从静态上下文中引用” (non-static variable cannot be referenced from a static context)的编译错误。
转载请注明原文地址:https://jikaoti.com/ti/7RH0FFFM
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
在软件开发中,需求分析阶段产生的主要文档是
下列叙述中正确的是
执行如下代码:fname=input(’’请输入要写入的文件:’’)fo=open(fname,’’w+’’)ls=[’’清明时节雨纷纷,’’,’’路上行人欲断魂,’’,’’借问酒家何处有?’’,\’’牧童遥指杏花村。’’]fo.writelin
补充完善如下代码。使得程序能够计算a中各元素与b逐项乘积的累加和。a=[[1,2,3],[4,5,6],[7,8,9]]b=[3,6,9]①forcina:forjin②:s+=c[j]*b[j]print(s)
文件ngchina.htm1保存了网页源代码,请将该页面中图片的URL提取出来,并输出所有图片的URL。输出格式如下:第1个URL:http://image.ngchina.com.cn/2018/0829/20180829012548753.jpg第2
执行下面代码,运行错误的是deff(x,y=0,z=0):pass
下列叙述中正确的是
下列叙述中正确的是()。
Java编译器产生的文件扩展名是______。
若串s=MathTypes",则其子串的数目是【】。
随机试题
胎膜早破不会引起的并发症是
若弯矩设计值ML=161.5kN·m,Mk=-206.9kN·m,则连梁的纵向受力钢筋面积为As=A’s=______mm2。上题中若Vmax=348.6kN,重力荷载代表值作用下按简支梁计算的连续剪力设计值VGb=18.31kN。则连梁的箍筋配置下列
按照建设项目基本程序,各阶段的主要工作划分清楚,则决策阶段的主要工作有()。
下列关于加强指数法的说法,错误的有()。
13,动机最佳水平应是______程度的激活或唤起,此时对学习具有最佳效果。
只要教育得法,人人都可以成为歌唱家、科学家、诗人。
中国共产党第十九次全国代表大会的主题是:_________,高举中国特色社会主义伟大旗帜,决胜全面建成小康社会,夺取新时代中国特色社会主义伟大胜利,为实现中华民族伟大复兴的中国梦不懈奋斗。填入画横线部分最恰当的一项是:
甲在抢劫时,突然产生幻觉,看见警车驶来,于是自动放弃犯罪。甲的行为属于()
若,则a=_______,b=_______.
项目控制是信息系统开发的重要技术手段,下述因素()是项目控制应考虑的内容:Ⅰ.资源保Ⅱ.进度控制Ⅲ.计划调整Ⅳ.费用统计
最新回复
(
0
)