下面程序的运行结果( )public class Demo{public static int fun(int c){return c+=2;}public static void main(String[] args){int temp=fun(2);System.out.println(temp);}}
A: 2
B: 4
C: 6
D: 8
A: 2
B: 4
C: 6
D: 8
举一反三
- (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); } }
- 写出程序的运行结果。 public class Demo{ public static void main(String args[]) { int b = get(); System.out.println(b); } public static int get() { try { return 1; } finally { return 2; } } }
- 下面程序运行结果为___________________。public class MyClass{ private static int a = 19; public static void modify(int a){ a = a + 5;} public static void main(String[] args){ modify(a); System.out.println(a); }}
- 下面程序的运行结果是 public class Test { public static void main(String[] args) { int temp = 0; for (int i = 1; i < 5; i++) { for (int j = 0; j < i; j++) { temp++; } } System.out.println(temp); } }
- 阅读下面程序,程序的运行结果是( )。public class Example {public static void main(String[] args) {int area = getArea(3, 5);System.out.println(" The area is " + area);}public static int getArea(int x, int y) {int temp = x * y; return temp; }} A: 编译错误 B: The area is 3 C: The area is 5 D: The area is 15