【单选题】【消耗次数:1】
关于以下application的说明,正确的是( ) 1. class StaticStuff 2. { 3. static int x=10; 4. static { x+=5;} 5. public static void main(String args[ ]) 6. { 7. System.out.println(“x=” + x); 8. } 9. static { x/=3;} 10. }
4行与9行不能通过编译,因为缺少方法名和返回类型
9行不能通过编译,因为只能有一个静态初始化器
编译通过,执行结果为:x=5
编译通过,执行结果为:x=3
参考答案:
复制
纠错
➡️如需代学继续教育,联系微信:yizhituziang

相关题目
【单选题】 编译运行以下程序后,关于输出结果的说明正确的是 ( ) public class Conditional{ public static void main(String args[ ]){ int x=4; System.out.println(“value is “+ ((x>4) ? 9.9:9)); } }
①  输出结果为:value is 99.9
②  输出结果为:value is 9
③  输出结果为:value is 9.0
④  编译错误
【单选题】 关于以下程序代码的说明正确的是( ) 1.class HasStatic{ 2. private static int x=100; 3. public static void main(String args[ ]){ 4. HasStatic hs1=new HasStatic( ); 5. hs1.x++; 6. HasStatic hs2=new HasStatic( ); 7. hs2.x++; 8. hs1=new HasStatic( ); 9. hs1.x++; 10. HasStati@@x- -; 11. System.out.println(“x=”+x); 12. } 13. }
①  5行不能通过编译,因为引用了私有静态变量
②  10行不能通过编译,因为x是私有静态变量
③  程序通过编译,输出结果为:x=103
④  程序通过编译,输出结果为:x=102
【单选题】 下列程序的运行结果是( ) 。 public class X5_1_2 extends x{ int ab() { static int aa=10; aa++; System.out.println(aa); } public static void main(String[] args) { X5_1_2 x=new X5_1_2(); x.ab(); } }
①  10
②  11
③  编译错误
④  运行成功,但不输出
【单选题】 下列程序执行的结果是( ) 。 public class X7_1_6 { public static void main(String[] args) { try{ return; } finally{ System.out.println(Finally); } } }
①  程序正常运行,但不输出任何结果
②  程序正常运行,并输出 Finally
③  编译通过,但运行时出现异常
④  因为没有 catch 子句,因此不能通过编译
【单选题】 已知有下面类的说明: public class X5_1_1 extends x{ private float f =10.6f; int i=16; static int si=10; public static void main(String[] args) { X5_1_1 x=new } } X5_1_1(); 在 main()方法中,下面哪条语句的用法是正确的?( )
①  x.f
②  this.si
③  X5_1_1.i
④  X5_1_1.f
【单选题】 运行下面程序时,会产生什么异常?( ) public class X7_1_5 { public static void main(String[] args) { int[] z = { 1,2,3,4 } ; int p = z[4]; int x = 0; int y = 5/x; } }
①  ArithmeticException
②  NumberFormatException
③  ArrayIndexOutOfBoundsException
④  IOException
【单选题】 下面代码运行后的输出结果为( ) 。 public class X6_1_5 { public static void main(String[] args) { AB aa = new AB(); AB bb; bb = aa; System.out.println(b@@equals(aa)); } } class AB{ int x = 100; }
①  true
②  false
③  编译错误
④  100
【单选题】 运行下面程序时,会产生什么异常?( ) public class X7_1_4 { public static void main(String[] args) { int x = 0; int y = 5/x; int[] z = { 1,2,3,4 } ; int p = z[4]; } }
①  ArithmeticException
②  NumberFormatException
③  ArrayIndexOutOfBoundsException
④  IOException
【单选题】 以下程序的运行结果是:( ) public class Increment{ public static void main(String args[]){ int c; c = 2; System.out.println(@@; System.out.println(c++); System.out.println(@@; } }
①  2 2 2
②  2 3 3
③  2 2 3
④  3 4 4
【单选题】 编译下面源程序会得到哪些文件( )? class A1{ } class A2{ } public class B{ public static void main(String[] args) { } }
①  只有B.class 文件
②  只有 A1.class 和 A2.class 文件
③  编译不成功
④  A1.class、A2.class 和B.class 文件
随机题目
【单选题】 顺义一中附小课程体系化、整合化设计与实施项目三年级确定的主题是()。
①  玩具总动员
②  在春天里长大
③  潮白河
④  致信童年
【单选题】 《学前教育国家质量标准》被誉为澳大利亚学前教育的“金标”,规定了影响儿童发展结果的()个质量领域。
①  6
②  7
③  8
④  9
【单选题】 实践活动现场体验是主题单元探究课程的()。
①  核心内容
②  主要内容
③  外在组成
④  内在组成
【单选题】 PYP项目将知识按照()大主题分类,采用世界上最先进的探索型学习模式。
①  5
②  6
③  7
④  8
【单选题】 2019年5月,教育部首次以“职业大学”命名批准了()所高校举办本科层次职业教育。
①  12
②  13
③  14
④  15
【多选题】 未来社会与国家发展对人才素质的要求包括要具备()能力。
①  沟通交流
②  合作协作
③  分析总结
④  批判性思维
⑤  创造创新
【多选题】 “一核四层四翼”中“四层”指()。
①  必备知识
②  关键能力
③  学科素养
④  核心价值
⑤  道德品质
【多选题】 进行课程整合的原因有()。
①  学校课程结构的问题
②  学习的多方面联结
③  中高考改革倒逼
④  培养未来人才的需要
⑤  学校之间的竞争
【多选题】 亦庄实验小学全课程的特点有()。
①  以全人教育为目标
②  以国家课程标准为引领
③  以项目学习为抓手
④  以跨学科融合为基本策略
⑤  覆盖学校全部生活的课程体系
【多选题】 “职教20条”中提到,5-10年要实现哪三个转变?()
①  由政府主办为主向政府统筹管理、社会多元办学的格局转变
②  由追求规模扩张向提高质量转变
③  由自主招生向扩大招生转变
④  由参照普通教育办学模式向企业社会参与、专业特色鲜明的类型教育转变
⑤  由国内办学向国际办学转变