(4-1)写出下面程序运行结果。 public class Demo5 { public static void main(String []args) { int[] arr={12,35,8,7,2}; Arrays.sort(arr); System.out.println(arr[3]*arr.length); } }
60
举一反三
- (4-3)写出以下程序运行结果。 public class Demo05 { public static void main(String[] args) { int temp = 0; int[][] arr = { { 3, 4, 5 }, { 7, 8, 2 }, { 1 }, { 6, 2, 8 } }; for (int[] list : arr) for (int x : list) { if(x>3) temp += list.length; } System.out.println(temp); } }
- 1. 请阅读下面的程序 class Demo{ public static void main(String[] args){ int[][] arr = ______ System.out.println(arr[2][1]); } } 在空白处填写代码,令程序编译成功
- 请阅读程序,然后写出程序运行结果。 public class Demo7 { public static void main(String[] args) { int [] arr= new int[5]; int sum=0; Arrays.fill(arr, 3); for(int x:arr) { sum=sum+x; } System.out.println(sum); } }
- (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)); } }
- 根据下面给出的代码,判断那个叙述是对的?public class Person{static int arr[]=new int[10];public static void main(String a[]){System.out.println(arr[1]);}}
内容
- 0
(2-6)请写出下面程序运行结果。 public class Demo { public static void main(String[] args) { int b = 011001; System.out.println(b); } }
- 1
(2-5)写出下面程序运行结果。 public class Demo { public static void main(String args[]) { System.out.println(123); System.out.println(0123); System.out.println(0x123); } }
- 2
(2-6)写出下面程序运行结果。 public class Demo { public static void main(String args[]) { int a=10,b=20; a=a^b; b=b^a; System.out.println(a); System.out.println(b); } }
- 3
智慧职教: 下面程序的运行结果是( ) public class Person{ int[] arr=new int[10]; public static void main(String[] args){ System.out .println(arr[9]); } }
- 4
(4-1)写出下面程序运行结果。public class Demo5 {pu...[3]*arr.length);}}