Tag Archives: array

Given the code fragment: (Exhibit) And given the requirements: 1. Process all the elements of the array

Given the code fragment:And given the requirements:1. Process all the elements of the array in the reverse order of entry.2. Process all the elements of the array in the order of entry.3. Process alternating elements of the array in the order of entry.Which two statements are true? (Choose two.) A. Requirement 2 can be implemented by using the… Read More »

Given the code fragment: int[] array = {1, 2, 3, 4, 5}; And given the requirements: 1. Process all the

Given the code fragment:int[] array = {1, 2, 3, 4, 5};And given the requirements:1. Process all the elements of the array in the order of entry.2. Process all the elements of the array in the reverse order of entry.3. Process alternating elements of the array in the order of entry.Which two statements are true? A. Requirements 2 and… Read More »

The following grid shows the state of a 2D array: (Exhibit) This grid is created with the following code:

The following grid shows the state of a 2D array:This grid is created with the following code:Which line of code, when inserted in place of //line n1, adds an X into the grid so that the grid contains three consecutive X’s? A. grid[2][0] = ‘X’; B. grid[0][2] = ‘X’; C. grid[1][2] = ‘X’; D. grid[1][3] = ‘X’; E.… Read More »

Which two statements are true for a two-dimensional array of primitive data type?

Which two statements are true for a two-dimensional array of primitive data type? A. It cannot contain elements of different types. B. The length of each dimension must be the same. C. At the declaration time, the number of elements of the array in each dimension must be specified. D. All methods of the class object may be… Read More »

Given the code fragment: (Exhibit) And given the requirements: 1. Process all the elements of the array

Given the code fragment:And given the requirements:1. Process all the elements of the array in the order of entry.2. Process all the elements of the array in the reverse order of entry.3. Process alternating elements of the array in the order of entry.Which two statements are true? (Choose two.) A. Requirement 1 can be implemented by using the… Read More »

Given: public class TestLoop { public static void main(String[] args) { int array[] = {0, 1, 2, 3, 4};

Given:public class TestLoop {public static void main(String[] args) {int array[] = {0, 1, 2, 3, 4};int key = 3;for (int pos = 0; pos < array.length; ++pos) {if (array[pos] == key) {break;}}System.out.print(“Found ” + key + “at ” + pos);}}What is the result? A. Found 3 at 2 B. Found 3 at 3 C. Compilation fails D. An… Read More »

Given the code fragment: — int[] array = {I, 2, 3, 4, 5}; And given the requirements: Process all the

Given the code fragment:—int[] array = {I, 2, 3, 4, 5};And given the requirements:Process all the elements of the array in the order of entry. Process all the elements of the array in the reverse order of entry. Process alternating elements of the array in the order of entry.Which two statements are true? A. Requirement 3 CANNOT be… Read More »