执行()程序段之后将出现错误提示。
A: int[]arr={11,21,31}; for(intx:arr) System.out.println(x);
B: Object[]obj=newString[]{"111","2222","3333"}; String[]str=(String[])obj;
C: Object[]obj={"111","2222","3333"}; String[]str=(String[])obj;
D: Object[]arr=newFloat[]{11.1F,22.1F,33.3F,44.44F,55.55F}; for(Floatx:(Float[])arr) System.out.println(x);
A: int[]arr={11,21,31}; for(intx:arr) System.out.println(x);
B: Object[]obj=newString[]{"111","2222","3333"}; String[]str=(String[])obj;
C: Object[]obj={"111","2222","3333"}; String[]str=(String[])obj;
D: Object[]arr=newFloat[]{11.1F,22.1F,33.3F,44.44F,55.55F}; for(Floatx:(Float[])arr) System.out.println(x);
举一反三
- (7-13)请阅读程序,写出程序运行结果。 //运行结果题 public class Demo4 { public static int print(Object obj) { int []arr; int sum=1; if(obj instanceof int[]) { arr=(int[])obj; for(int x:arr) { sum=arr.length+sum; } } return sum; } public static void main(String[] args) { int []arr= {1,2,3,4,5}; String [] list= {"孙悟空","猪八戒","唐僧"}; System.out.println(print(arr)+print(list)); } }
- 下面代码在运行时会产生什么异常?( ) Object obj = new Object();String str = (String)obj; A: ClassNotFoundException B: ClassCastException C: ObjectClassException D: NullPointerException
- 如下代码在控制台打印结果为: var obj = {1 : 1}; var arr = [1,1]; console.log(obj + arr); A: 1 B: 2 C: [object Object]1,1 D: 1,1[object Object]
- 通过()方法可以将内容保存在session中。 A: session.setValues(String name,Object obj) B: session.setAttribute(String namej) C: session.setAttribute(String name,Object obj) D: session.getValues(String name)
- 先阅读下面的程序片段: String str = 'abccdefcdh'; String[] arr = str.split('c'); System.out.println(arr.length); 程序执行后,打印的结果是几?( )