读代码:public class foo {static String s;public static void main (String[]args) {System.out.println (“s=” + s);}}结果是:
A: The code compiles, but a NullPointerException is thrown when toString is called
B: The code compiles and “s=null” is printed
C: The code does not compile because string s cannot be referenced
D: The code does not compile because string s is not initialized
E: The code compiles and “s=” is printed
A: The code compiles, but a NullPointerException is thrown when toString is called
B: The code compiles and “s=null” is printed
C: The code does not compile because string s cannot be referenced
D: The code does not compile because string s is not initialized
E: The code compiles and “s=” is printed
举一反三
- 读代码:public class foo {static String s;public static void main (String[]args) {System.out.println (“s=” + s);}}结果是
- 阅读以下代码: public class foo{ public static void main (String[] args){ String s; System.out.println("s=" + s); 输出结果应该是
- 下列程序运行后的输出结果是_______public class Foo{ public static void main(String[] args){ String s; System.out.println(“s=” + s); }} A: 编译错误 B: s=s C: s= D: s=null
- 下面代码的运行结果为:( ) import java.io.*; import java.util.*; public class foo{ public static void main (String[] args){ String s; System.out.println("s=" + s); } }
- 给定java代码,如下:编译运行,结果是。 Public static void main(String[]) args) { String s; System.out.println(“s=”+s); }