5. Arrays

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

The statement shows an example of int Gs [] = { 100, 90, 99, 80}; A. default arguments B. an illegal array declaration C. an illegal array initialization D. implicit array sizing

ANSWER: D

What is the last element of: int Gs[] = { 100, 90, 99, 80}; A. G[4] B. G.charAt(3) C. G(3) D. G[3]

ANSWER: D

What is the last legal index that can be used with the following array? int V[5]; a.0 b.5 c.6 D. 4

ANSWER: D

What will the following code do? int SIZE = 5; double []A=new double [SIZE]; A. Each element in the array is initialized to 0 B. Each element in the array, except the first, is initialized to 0.0 C. Each element in the array, except the first and the last, is initialized to 0.0 D. Each element in the array is initialized to 0.0

ANSWER: D

Which of the following is a valid Java array definition? A. int S[0] = new int[0]; B. float $pay[10] = new float [10]; C. int R[4.7] D. int S [] = new int[10];

ANSWER: D

An array can easily be stepped through by using a A. for loop B. reference variable C. named constant D. null value

ANSWER: A

An array can store a group of values, but the values must be A. the same data type B. each of a different data type C. constants D. integers

ANSWER: A

For the traversal of an array int A[] use the following loop: A. for(int i = 0; i < A.length; i++) {..} B. for(int i = 1; i < length(A); i++) {..} C. for(int i = 1; i < length(A); i++) {..} D. for(int i = 0, i < length(A), i++) {..}

ANSWER: A

How many elements does the following array have? int Bs[100]; A. 100 B. 999 C. 101 D. Cannot tell from the code

ANSWER: A

If String S[] = {"ann","dan","jo"}; what will be displayed: System.out.print(Arrays.toString(S));? A. [ann, dan, jo] B. ann dan jo C. "ann dan jo" D. {ann, dan, jo}

ANSWER: A

Sort an array of numbers Ar[n]: A. Arrays.sort(Ar); B. sort(Ar); C. Ar.sort(); D. Ar.Arrays.sort();

ANSWER: A

Switch the first element with the last in an array A[n]: A. int w = A[0]; A[0] = A[n-1]; A[n-1] = w; B. A[0] = A[n-1]; A[n-1] = A[0]; C. int w = A[1]; A[0] = A[n-1]; A[n-1] = w; D. int w = A[n-1]; A[0] = A[n-1]; A[n-1] = w;

ANSWER: A

Use an initialization list to specify the values of an array: A. int []A ={6,2,1,4,7}; B. int []A = [6,2,1,4,7]; C. A ={6,2,1,4,7}; D. int A ={6,2,1,4,7};

ANSWER: A

What is the value of Ns[3]? int Ns[] = {99, 87, 66, 55, 101}; A. 55 B. 66 C. 101 D. 87

ANSWER: A

Check if two arrays A[] and B[] are equal: A. A == B B. Arrays.equals(A,B) C. A = B D. A.equals(B)

ANSWER: B

Display an array int A[] in reverse: A. for(int i = A.length; i >= 0; i--) {System.out.print(A[i])}; B. for(int i = A.length-1; i >= 0; i--) {System.out.print(A[i])}; C. for(int i = A.length; i > 0; i--) {System.out.print(A[i])}; D. for(int i = A.length; i <= 0; i--) {System.out.print(A[i])};

ANSWER: B

The individual values contained in array are known as A. parts B. elements C. numbers D. constants

ANSWER: B

To access an array element, use the array name and the element's A. data type B. subscript/index C. name D. value

ANSWER: B

What will the following code display? int Ns[]={99, 87}; System.out.print(Ns[3]); A. 87 B. error index out of bound C. garbage D. 0

ANSWER: B

An array's size declarator must be a(n)__ with a value greater than ___. A. number, one B. number, zero C. constant integer expression, zero D. variable, -1

ANSWER: C

By using the same ____ you can build relationships between data stored in two or more arrays. A. array name B. data C. subscript/index D. arguments

ANSWER: C

Given the following declaration, where is 7 stored in the scores array? int S[]={8,6,7,9}; A. S[0] B. S[1] C. S[2] D. S[4]

ANSWER: C

How do you find the size of: int []A ={6,2,1,4,7}; A. A.size B. size(A) C. A.length D. A.length()

ANSWER: C

Print an array A[n] of numbers/characters or Strings: A. System.out.print(A); B. System.out.print(Arrays.String(A)); C. System.out.print(Arrays.toString(A)); D. System.out.print(toString(A));

ANSWER: C

To assign the contents of one array int A[]={1,2,3} to another int B[]: A. int B [] = A; B. int B[] = A[]; C. B = A; D. int B [] = A.clone();

ANSWER: C

Unlike regular variables, these can hold multiple values. A. constants B. named constants C. arrays D. floating-point variables

ANSWER: C

What will the code display? int Ns[]={9,8,6,5,1}; for(int i = 1; i < 4; i++) System.out.print(Ns[i]," "); A. 9 8 6 5 1 B. 8 6 5 1 C. 8 6 5 D. Nothing. This code has an error.

ANSWER: C

Index numbering in Java A. can begin with 1 B. can begin with a programer-defined value C. varies from program to program D. begins with zero

ANSWER: D


संबंधित स्टडी सेट्स

Econ Final (Chapter Tests Questions)

View Set

MAR3023 Brady Exam 3 (Ch. 11-16) Tb Questions

View Set

A&P Final (Autonomic Nervous System)

View Set

Lab Simulation 3-1: Working with Steganography

View Set

California Real Estate LAWS OF AGENCY AND FIDUCIARY DUTIES

View Set