【单选题】【消耗次数: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
参考答案:
复制
纠错
相关题目
【单选题】 编译运行以下程序后,关于输出结果的说明正确的是 ( ) 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 文件
随机题目
【多选题】 三圈环流的形成是()共同作用的结果。
①  内摩擦力
②  外摩擦力
③  水平气压梯度力
④  惯性离心力
⑤  水平地转偏向力
【多选题】 对流层的特点包括()。
①  空气温、湿度等气象要素在水平方向上分布比较均匀
②  空气主要作水平运动
③  气温日变辐大
④  随高度增加风速减小
⑤  水汽和尘埃含量多
【多选题】 我国是著名的季风区,夏季盛行()。
①  东南风
②  东北风
③  西南风
④  西北风
⑤  东风
【单选题】 农业气象的基本要素是()。
①  温度、湿度、光照、土壤水分
②  光照、热量、水分、气
③  热量、光照、光照、水分
④  光照、温度、水分、积温
【单选题】 春天出现的霜冻称为()。
①  早霜冻
②  中霜冻
③  晚霜冻
④  晨霜冻
【单选题】 海陆的热力差异是产生季风的原因之一,夏季风的形成是因为()。
①  夏季大陆温度高,气压低;海洋温度低,气压高
②  夏季大陆温度高,气压高;海洋温度低,气压低
③  夏季大陆温度低,气压高;海洋温度高,气压低
④  夏季大陆温度低,气压低;海洋温度高,气压高
【单选题】 初步建成结构科学、布局合理、功能先进的()现代农业气象服务体系。
①  市、县
②  省、市、县
③  国家、省、市、县
④  国家、区域、省、市、县
【多选题】 梯度风是自由大气中空气所受()相平衡时的运动。
①  水平气压梯度力
②  水平地转偏向力
③  惯性离心力
④  重力
⑤  浮力
【多选题】 《中国气象事业发展战略研究》现代气象业务卷中生态系统监测分为()等8项。
①  农田生态监测
②  森林生态监测
③  草地生态监测
④  湿地生态监测
【多选题】 对流层()。
①  含有大量的臭氧
②  集中了大气质量的3/4
③  集中了几乎全部的水汽
④  云、雨等主要天气现象都发生在该层