【单选题】【消耗次数: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
③  编译错误
④  运行成功,但不输出
随机题目
【单选题】 某进程由于需要从磁盘上读入数据而处于阻塞状态。当系统完成了所需的读盘操作后,此时该进程的状态将( )。
①  从就绪变为运行
②  从运行变为就绪
③  从运行变为阻塞
④  从阻塞变为就绪
【单选题】 在操作系统中,进程的最基本的特征是( )。
①  动态性和并发性
②  顺序性和可再现性
③  与程序的对应性
④  执行过程的封闭性
【单选题】 进程间的基本关系为( )。
①  相互独立与相互制约
②  同步与互斥
③  C.并行执行与资源共享
④  信息传递与信息缓冲
【单选题】 在执行V操作时,当信号量的值( ),应释放一个等待该信号量的进程。
①  小于0
②  大于0
③  小于等于0
④  大于等于0
【单选题】 两个进程合作完成一个任务,在并发执行中,一个进程要等待其合作伙伴发来信息,或者建立某个条件后再向前执行,这种关系是进程间的( )关系。
①  同步
②  互斥
③  竞争
④  合作
【单选题】 在一段时间内,只允许一个进程访问的资源称为( )。
①  共享资源
②  临界区
③  临界资源
④  共享区
【单选题】 下列进程状态的转换中,不正确的是( )。
①  就绪→阻塞
②  运行→就绪
③  就绪→运行
④  阻塞→就绪
【单选题】 在进程通信中,使用信箱方式交换信息的是( )。
①  低级进程通信
②  高级进程通信
③  共享内存方式
④  管道文件方式
【单选题】 进程在系统中存在的唯一标志是( )。
①  所运行的程序
②  所运行的程序和数据
③  进程队列
④  进程控制块
【单选题】 多个进程的实体能存在于同一内存中,在一段时间内都得到运行。这种性质称作进程的( )。
①  动态性
②  并发性
③  调度性
④  异步性