4、 The program runs and prints 2 followed by \int)\is invoked.
5、 The program runs and prints \by 2. 答案 2 第 73题 The client can use a method without knowing how it is implemented. The details of the implementation are encapsulated in the method and hidden from the client who invokes the method. This is known as __________. 1、 information hiding 2、 encapsulation 3、 method hiding
4、 simplifying method 答案 1 2 第 74
题 What is
Math.floor(3.6)? 1、 3.0 2、 3
3、 4 4、 5.0 答案 1 第 75题 If you declare an array double[] list = {3.4, 2.0, 3.5, 5.5}, list[1] is ________. 1、 3.4 2、 2.0 3、 3.4
4、 5.5 5、 undefined 答案 2 第 76题 If you declare an array double[] list = {3.4, 2.0, 3.5, 5.5}, the highest index in array list is __________. e, 4 1、 0 2、 1
3、 2 4、 3 答案 4 第 77题 Suppose int i = 5, which of the following can be used as an index for array double[] t = new double[100]? 1、 i
2、 (int)(Math.random() * 100)) 3、 i + 10 4、 i + 6.5
5、 Math.random() * 100 答案 1 2 3 第 78题 Analyze the following code. public class Test { public static void main(String[] args) { int[] x = new int[3];
System.out.println(\ }
}
1、 The program has a compile error because the size of the array wasn t specified when declaring the array.
2、 The program has a runtime error because the array elements are not initialized.
3、 The program runs fine and displays x[0] is 0.
4、 The program has a runtime error because the array element x[0] is not defined. 答案 3 第 79题 What would be the result of attempting to compile and run the following code? public class Test { public static void main(String[] args) { double[] x = new double[]{1, 2, 3}; System.out.println(\ } }
1、 The program has a compile error because the syntax new double[]{1, 2, 3} is wrong and it should be replaced by {1, 2, 3}.
2、 The program has a compile error because the syntax new double[]{1, 2, 3} is wrong and it should be replaced by new double[3]{1, 2, 3}; 3、 The program has a compile error because the syntax new double[]{1, 2, 3} is wrong and it should be replaced by new double[]{1.0, 2.0, 3.0}; 4、 The program compiles and runs fine and the output \printed.
5、 The program compiles and runs fine and the output \is 2.0\答案 5 第 80题 Analyze the following code: public class Test { public static void main(String[] args) { int[] x = new int[5];
int i; for (i = 0; i < x.length; i++) x[i] = i;
System.out.println(x[i]); } }
1、 The program displays 0 1 2 3 4. 2、 The program displays 4.
3、 The program has a runtime error because the last statement in the main method causes ArrayIndexOutOfBoundsException.
4、 The program has a compile error because i is not defined in the last statement in the main method.
答案 3 第 81题 In the following code, what is the printout for list2?
class Test { public static void
main(String[] args) { int[] list1 = {1, 2, 3}; int[] list2 = {1, 2, 3}; list2 = list1; list1[0] = 0; list1[1] = 1; list2[2] = 2; for (int i = 0; i < list2.length; i++)
System.out.print(list2[i] + \ } }
1、 1 2 3 2、 1 1 1 3、 0 1 2
4、 0 1 3 答案 3 第 82题 In the following code, what is the printout for list1? class Test { public static void
main(String[] args) { int[] list1 = {1, 2, 3}; int[] list2 = {1, 2, 3}; list2 = list1; list1[0] = 0; list1[1] = 1; list2[2] = 2; for (int i = 0; i < list1.length; i++)
System.out.print(list1[i] + \ } }
1、 1 2 3 2、 1 1 1
3、 0 1 2 4、 0 1 3 答案 3 第 83题 Analyze the following code: public class Test { public static void main(String[] args) { int[] x = {1, 2, 3, 4}; int[] y = x; x = new int[2]; for } }
1、 The program displays 1 2 3 4 2、 The program displays 0 0
(int
i
=
0;
i
<
x.length;
i++)
System.out.print(x[i] + \
3、 The program displays 0 0 3 4 4、 The program displays 0 0 0 0 答案 2 第 84题 Analyze the following code: public class Test { public static void main(String[] args) { final int[] x = {1, 2, 3, 4}; int[] y = x; x = new int[2];
for (int i = 0; i < y.length; i++) System.out.print(y[i] + \ } }
1、 The program displays 1 2 3 4 2、 The program displays 0 0
3、 The program has a compile error on the statement x = new int[2], because x is final and cannot be changed.
4、 The elements in the array x cannot be changed, because x is final. 答案 3 第 85题 Analyze the following code: public class Test { public static void main(String[] args) { int[] a = new int[4]; a[1] = 1; a = new int[2];
System.out.println(\ } }
1、 The program has a compile error because new int[2] is assigned to a. 2、 The program has a runtime error because a[1] is not initialized. 3、 The program displays a[1] is 0. 4、 The program displays a[1] is 1. 答案 3 第 86题 Show the output of the following code: public class Test { public static void main(String[] args) { int[] x = {1, 2, 3, 4, 5}; increase(x); int[] y = {1, 2, 3, 4, 5}; increase(y[0]);
System.out.println(x[0] + \ } public static void increase(int[] x) { for (int i = 0; i < x.length; i++) x[i]++; } public static void increase(int y) { y++; } } 1、 0 0 2、 1 1 3、 2 2
4、 2 1 5、 1 2 答案 4 第 87题 programs produce the same result? Program I:
public class Test { public static void main(String[] args) { int[] list = {1, 2, 3, 4, 5}; reverse(list);
for (int i = 0; i < list.length; i++) System.out.print(list[i] + \ } public static void reverse(int[] list)
{
int[]
newList
=
new int[list.length]; for (int i = 0; i < list.length; i++)
newList[i]
=
list[list.length - 1 - i]; list =
newList; }
} Program II:
public class Test { public static void main(String[] args) { int[] oldList = {1, 2, 3, 4, 5}; reverse(oldList); for (int i = 0; i < oldList.length; i++) System.out.print(oldList[i] + \ } public static void reverse(int[] list)
{
int[]
newList
=
new
int[list.length]; for (int i = 0; i < list.length; i++)
newList[i]
=
list[list.length - 1 - i]; list =
newList;
Do the following two