True or False: In Java, array indexes are zero-based.
Question 21 pts
Which of the following will correctly create an array of 8integers in Java?
| int[ ] myArray = new int[7]; |
| int[ ] myArray = new int[9]; |
| int myArray = new int[8]; |
| int[ ] myArray = new int[8]; |
Question 31 pts
True or False: The major advantage of Arrays over ArrayLists inJava is the fact that while ArrayLists are fixed in size, an Arraycan increase or decrease in size as needed.
Question 41 pts
Given the following array declaration and instantiation in Java,what is the index of the last value in the array?
int[ ] myArray = new int[3];
| No array will be created. |
1 pts
Given the following array declaration and instantiation in Java,what is the index of the last value in the array?
int myArray = new int(3);
| No array will be created. |
1 pts
Given the following array declaration and instantiation in Java,what is the index of the first value in the array?
int[ ] myArray = new int[3];
| No array will be created. |
Question 71 pts
Consider the following small Java program. What will the outputbe?
public class Driver { public static void main(String[ ] args) { int[ ] x = {6,9,2,3,8,1,4,7,5}; System.out.println(x[5]); }}
Question 81 pts
Consider the following small Java program. What will the outputbe?
public class Driver { public static void main(String[ ] args) { int[ ] x = {6,4,9,2,1,8,5,7,3,0}; int a = 3; System.out.println(x[a + 1]); }}
Question 91 pts
Consider the following small Java program. What will the outputbe?
public class Driver { public static void main(String[ ] args) { int[ ] x = {6,4,9,2,1,8,5,7,3,0}; int a = x[3]; System.out.println(x[a + 3]); }}
Question 101 pts
Consider the following small Java program. What will thecontents of the array x be when the code finishesrunning?
public class Driver { public static void main(String[ ] args) { int[ ] x = {3,1,5,2,4}; int a = 0; for (int index = 0; index < x.length - 1; index++) { if ( x[index] > x[index + 1]) { a = x[index]; x[index] = x[index + 1]; x[index + 1] = a; } } }}