举一反三
- 阅读下面的程序public class Example{ public static void main(String[] args) { String[] strs = { "Tom", "Jerry", "Donald" }; // foreach循环遍历数组 for (String str : strs) { str = "Tuffy"; } System.out.println(strs[0] + "," + strs[1] + "," + strs[2]); }}程序的运行结果是( ) A: Tom,Jerry,Donald B: Tuffy,Jerry,Donald C: Tuffy, Tuffy, Tuffy D: 发生异常,输出异常信息
- 阅读下面的程序public class Example{public static void main(String[] args) {String[] strs = { "Tom", "Jerry", "Donald" };// foreach循环遍历数组for (String str : strs) {str = "Tuffy";}System.out.println(strs[0] + "," + strs[1] + "," + strs[2]);}}下列选项中,程序的运行结果是( ) A: Tom,Jerry,Donald B: Tuffy,Jerry,Donald C: Tuffy,Tuffy,Tuffy D: 发生异常,输出异常信息
- 阅读下面的程序public class Example{ public static void main(String[] args) { String[] strs = { "Tom", "Jerry", "Donald" }; // foreach循环遍历数组 for (String str : strs) { str = "Tuffy"; } System.out.println(strs[0] + "," + strs[1] + "," + strs[2]); }}下列选项中,程序的运行结果是( ) A: A、Tom,Jerry,Donald B: B、Tuffy,Jerry,Donald C: C、Tuffy,Tuffy,Tuffy D: D、发生异常,输出异常信息
- 阅读下面的代码:publicclassExample{publicstaticvoidmain(String[]args){String[]strs={"Tom","Jerry","Donald"};//foreach循环遍历数组for(Stringstr:strs){str="Tuffy";}System.out.println(strs[0]+","+strs[1]+","+strs[2]);}}程序的运行结果是() A: Tom,Jerry B: Tom,Jerry,Tuffy C: Tom,Jerry,Donald D: 以上都不对
- 中国大学MOOC: 如果有以下的程序代码:String[] [] strs {{Java,Java,Java},{Java,Java,Java,Java}System.out.println(strs.length) ; System.out.println(strs[0].length);System.out.print1n(strs[1].length);以下描述何者正确?
内容
- 0
如果有以下关于String[][]的程序代码:String[][] strs = new String[2][5];以下描述正确的是( ) A: 产生10个String实例 B: 产生2个String实例 C: 产生0个String实例 D: 编译失败
- 1
下列程序的运行结果是()public class Test {public static void main(String[] args) {String str = NULL;System.out.println(str);}} A:
- 2
如果有以下关于String[][]的程序代码: String[][] strs = new String[2][5]; 以下描述正确的是( )
- 3
如果有以下的程序代码: String[] [] strs { {"Java","Java","Java"}, {"Java","Java","Java","Java"} System.out.println(strs.length) ; System.out.println(strs[0].length); System.out.print1n(strs[1].length); 以下描述何者正确? A: 显示2、3、4 B: 显示2、0、1 C: 显示1、2、3 D: 编译失败
- 4
下列程序运行的结果是( )。public class Demo { public static void main(String[] args) { String[] strs = new String[3]; System.out.println(str[0].equals("abc")); }} A: true B: false C: 编译出错 D: 抛出NullPointerException空指针异常