Question: True or False: In Java, array indexes are zero-based. True False Question 21 pts Which of the following will correctly create an array of 8integers

True or False: In Java, array indexes are zero-based.

True
False

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];
None of these.
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.

True
False

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.
0
2
1
3
4

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);
0
3
4
2
1
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];
1
4
0
3
2
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]);     }}
8
4
5
1
9
6
7
2
There will be no output.
3

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]);     }}
3
5
0
1
9
There will be no output.
6
2
7
8
4

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]);     }}
0
3
There will be no output.
5
8
4
1
7
2
6
9

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;            }        }    }}
1,2,4,3,5
1,3,2,5,4
None of these.
3,1,2,4,5
1,3,2,4,5
2,1,3,5,4
3,4,1,5,2
2,1,3,5,4
5,4,3,2,1
1,2,3,4,5

Step by Step Solution

3.37 Rating (153 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!