我是靠谱客的博主 稳重书包,最近开发中收集的这篇文章主要介绍Java基础知识英语选择题6——Array, Vector, ArrayList,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

1. Consider the Java program below.

public class Arr{
public static void main(String[] args) {
int[] a = {1, 2, 3};
System.out.println(a[1]);
System.out.println(a[3]);
}
}

Which of the following is true about the result of executing the program?

A. The number 2 is printed and a run-time exeception terminates execution.

B. The number 2 is printed and there is no abnormal termination.

C. The number 1 is printed and there is no abnormal termination.

D. The number 3 is printed and a run-time exeception terminates.

Correct Answer: A

2. Regarding the following declaration, what is the index of the element containing 45?

int[] numbers = {-1, 45, 6, 132};

 A. 2

B. 0

C. 1

D. 45

Correct Answer: C

3. A Java array that contains n components will be indexed from through___.

A. 0, n-1

B. 1, n

C. 0, n

D. 1, n-1

Correct Answer: A

4. Consider the following Java program segment.

String[] str = {"Three", "Two", "One"};
for (int i = 0; i < str.length; ++i) {
System.out.println(str[i] + "/");
}

What will be output upon execution of the program segment?

A. Three/Two/One

B. One/Two/Three

C. One,Two,Three

D. Three,Two,One

Correct Answer: A

5. Legal Java statements to initialize an array reference include which of the following?

  1. int[] aobj = {0, 1, 2};

  2. int[4] aobj = {0, 1, 2};

  3. int[] aobj = new int[3]

A. Ⅱ only

B. Ⅰonly

C. Ⅲ only

D. Ⅰand Ⅲ only

Correct Answer: D

6. An object that contains methods that traverse an vector linearly from start to finish is known as a(n)____.

A.loop

B. iterator

C. int

D. Exception

Correct answer: B

7. The class java.util.ArrayList implements a collection that

A. cannot be accessed using an integer index

B. can only store instances of the class java.lang.String

C. can grow to accommodate new items

D. can only store primitive variables such as int or boolean

Correct Answer: C

8. In which of the following ways can items be added to a collection implemented by java.util.ArrayList?

  1. Items can be inserted at the beginning of the collection.

  2. Items can be inserted between two existing items in the collection.

  3. Items can be appended to the end of the collection. 

A. Ⅲ only

B. Ⅰ and Ⅲ only

C. Ⅰonly

D.  Ⅰ, Ⅱ and Ⅲ

Correct Answer: D

9. Consider the following method call, where v is an instance of the class java.util.Vector

v.size();

This method call returns the number of ____

A. bytes used by v

B. times that the method v.add has been called

C. Vector objects that have been instantiated

D. elements in the vector represented bt v

Correct Answer: D

10. Array elements may only be retrieved using___, whereas vector elements may also be retrieved using____.

A. indexes, iterators

B. iterators, indexs

C. names, indexes

D. indexes, names

Correct Answer: A

(部分题目来自网络,如有侵权,请联系文章作者删除)

最后

以上就是稳重书包为你收集整理的Java基础知识英语选择题6——Array, Vector, ArrayList的全部内容,希望文章能够帮你解决Java基础知识英语选择题6——Array, Vector, ArrayList所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(42)

评论列表共有 0 条评论

立即
投稿
返回
顶部