- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
java第六章
1. The arraycopy method does not allocate memory space for the target array. The target array must already be created with memory space allocated.
a. false
b. true
#
2. What is the output of the following code?
double[] myList = {1, 5, 5, 5, 5, 1};
double max = myList[0];
int indexOfMax = 0;
for (int i = 1; i myList.length; i++) {
if (myList[i] = max) {
max = myList[i];
indexOfMax = i;
}
}
System.out.println(indexOfMax);
a. 4
b. 0
c. 1
d. 2
e. 3
#
3. How many elements are in array double[] list = new double[5]?
a. 5
b. 4
c. 0
d. 6
#
4. 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] + + y[0]);
}
public static void increase(int[] x) {
for (int i = 0; i x.length; i++)
x[i]++;
}
public static void increase(int y) {
y++;
}
}
a. 2 2
b. 0 0
c. 1 2
d. 1 1
e. 2 1
#
5. The array index of the first element in an array is 0.
a. false
b. true
#
6. 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] + );
}
}
a. The program displays 1 2 3 4
b. The program displays 0 0
c. The program has a compile error on the statement x = new int[2], because x is final and cannot be changed.
d. The elements in the array x cannot be changed, because x is final.
#
7. If a key is not in the list, the binarySearch method returns _________.
a. insertion point
b. -insertion point
c. -(insertion point + 1)
d. insertion point - 1
#
8. Assume int[] scores = {1, 20, 30, 40, 50}, what value does java.util.Arrays.binarySearch(scores, 3) return?
a. -2
b. 1
c. 0
d. 2
e.
文档评论(0)