【单选题】【消耗次数: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
③  编译错误
④  运行成功,但不输出
随机题目
【判断题】 当主人亲自驾车时,若一个人乘车,则必须坐在副驾驶座上;若多人乘车,必须推举一个人在副驾驶座上就座,不然就是对主人的失敬。
①  正确
②  错误
【判断题】 在室内游泳馆下水前,不一定非要做热身操。
①  正确
②  错误
【单选题】 国际信函的信封上,收信者的地址和邮编应写在( )
①  信封左上方
②  信封正面的中央偏右下方
③  信封右上方
④  信封左下方
【判断题】 肃立站姿适用于商业服务。
①  正确
②  错误
【判断题】 行路中,如遇车祸或其他变故,不要围观起哄。
①  正确
②  错误
【判断题】 一般情况下,在日常生活中,名片可分两种:社交名片和公务名片。
①  正确
②  错误
【判断题】 同桌座次上,主人座位左边的位置比较尊贵。
①  正确
②  错误
【判断题】 QQ和微信的聊天及时回复也是应有的礼仪
①  正确
②  错误
【判断题】 探望病人选择礼品,只要上档次就好。
①  正确
②  错误
【判断题】 参加婚礼要喜庆,在着装越靓丽越好。
①  正确
②  错误