【单选题】【消耗次数:1】
阅读以下代码: import java.io.*; import java.util.*; public class foo{ public static void main (String[] args){ String s; System.out.println(s= + s); } } 输出结果应该是:( )
代码得到编译,并输出“s=”
代码得到编译,并输出“s=null”
由于String s没有初始化,代码不能编译通过
代码得到编译,但捕获到 NullPointException异常
参考答案:
复制
纠错
相关题目
【单选题】 编译运行以下程序后,关于输出结果的说明正确的是 ( ) 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
④  编译错误
【单选题】 编译下面源程序会得到哪些文件( )? 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 文件
【单选题】 下面代码运行后的输出结果为( ) 。 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 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
【单选题】 下列程序执行的结果是( ) 。 public class X7_1_6 { public static void main(String[] args) { try{ return; } finally{ System.out.println(Finally); } } }
①  程序正常运行,但不输出任何结果
②  程序正常运行,并输出 Finally
③  编译通过,但运行时出现异常
④  因为没有 catch 子句,因此不能通过编译
【单选题】 应用程序的main方法中有以下语句,则输出的结果是 ( )。 String s1=new String(abc); String s2=new String(abc); boolean b1=s1.equals(s2); boolean b2=(s1==s2); System.out.print(b1+ +b2);
①  true false
②  false true
③  true true
④  false false
【单选题】 下列程序从标准输入设备读入一个字符, 然后再输出到显示器, 选择正确的一项填入“//x” 处,完成要求的功能( ) 。 import java.io.*; public class X8_1_4 { public static void main(String[] args) { char ch; try{ //x System.out.println(ch); } catch(IOException e) { e.printStackTrace(); } } }
①  ch = System.in.read();
②  ch = (char)System.in.read();
③  ch = (char)System.in.readln();
④  ch = (int)System.in.read();
【单选题】 下列程序段执行后的结果是( )。 String s = new String(abcdefg); for (int i=0; i<s.length(); i+=2){ System.out.print(s.charAt(i)); }
①  aceg
②  ACEG
③  abcdefg
④  abcd
【单选题】 System.out.println(5 + 2);的输出结果应该是( )。
①  52
②  7
③  2
④  5
【单选题】 下列程序的运行结果是( ) 。 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
③  编译错误
④  运行成功,但不输出
随机题目
【单选题】 在直接受动力荷载作用的情况下,下列情况中采用()连接方式最为适合。
①  普通螺栓
②  角焊缝
③  对接焊缝
④  高强螺栓
【单选题】 土体的强度破坏是。( )
①  剪坏
②  拉坏
③  压坏
【单选题】 高耸结构物的地基允许变形值除了要控制绝对沉降量外,还要由下列何种性质控制( )
①  倾斜
②  平均沉降
③  沉降差
【单选题】 框架结构中布置填充墙后,结构的基本自振周期将( )
①  增大
②  减小
③  说不清
④  不变
【单选题】 下列药物中属于非苯二氮卓结构的杂环类镇静催眠药的是( )。
①  地西泮
②  劳拉西泮
③  佐匹克隆
④  阿普唑仑
⑤  三唑仑
【单选题】 帕罗西汀的作用机制是( )。
①  阻断5-HT受体
②  抑制突触前膜对去甲肾上腺素的再摄取
③  抑制A型单胺氧化酶,减少去甲肾上腺素、5-HT及多巴胺的降解
④  抑制突触前膜对5-HT及去甲肾上腺素的再摄取
⑤  选择性抑制5-HT的再摄取,增加突触间隙5-HT浓度
【单选题】 可降低多奈哌齐血浆药物浓度的是( )。
①  红霉素
②  氟西汀
③  酮康唑
④  苯妥英钠
⑤  伊曲康唑
【单选题】 解热镇痛抗炎药的作用机制是( )。
①  抑制PG的生物合成
②  减少PG的分解代谢
③  直接对抗PG的生物活性
④  阻断PG受体
⑤  直接抑制中枢神经系统
【单选题】 青光眼患者应慎用( )。
①  孟鲁司特
②  噻托溴铵
③  氨溴索
④  沙丁胺醇
⑤  沙美特罗
【单选题】 铋剂连续服用不得超过2个月,是因为长期服用可导致( )。
①  大便呈黑色
②  肝功损害
③  舌苔变黑
④  神经毒性
⑤  不孕