Podcast
Questions and Answers
In practice 6.09, what does the code segment count in the 'values' array?
In practice 6.09, what does the code segment count in the 'values' array?
What is missing in the code in practice 6.10 to correctly manipulate array elements?
What is missing in the code in practice 6.10 to correctly manipulate array elements?
How would you correctly call the 'display' method with the 'values' array in practice 6.11?
How would you correctly call the 'display' method with the 'values' array in practice 6.11?
How can you complete the 'firstPlusLast' method in practice 6.13 to return the sum of the first and last elements of an array?
How can you complete the 'firstPlusLast' method in practice 6.13 to return the sum of the first and last elements of an array?
Signup and view all the answers
Which of the following is the correct way to create an array with 20 double elements?
Which of the following is the correct way to create an array with 20 double elements?
Signup and view all the answers
Given the declaration int[] array = {4, 3, 5, 2, 0};, what is the value of array[2]?
Given the declaration int[] array = {4, 3, 5, 2, 0};, what is the value of array[2]?
Signup and view all the answers
Which of the following statements would cause a run-time error with the declaration int[] array = {4, 3, 5, 2, 0};?
Which of the following statements would cause a run-time error with the declaration int[] array = {4, 3, 5, 2, 0};?
Signup and view all the answers
What output is generated by the code segment below?
int[] values = new int[5];
for (int k = 0; k < values.length; k++) { values[k] = k * 2; }
System.out.println(values);
What output is generated by the code segment below? int[] values = new int[5]; for (int k = 0; k < values.length; k++) { values[k] = k * 2; } System.out.println(values);
Signup and view all the answers
Insert the missing statement in the code fragment to initialize the array elements with the values 1, 2, 3,..., 100.
int[] numbers = new int[100];
for (int k = 0; k < numbers.length; k++) { }
Insert the missing statement in the code fragment to initialize the array elements with the values 1, 2, 3,..., 100. int[] numbers = new int[100]; for (int k = 0; k < numbers.length; k++) { }
Signup and view all the answers
What output is generated by the code fragment below?
int[] values = {1, 3, 1, 3, 1};
int[] numbers = values;
for (int k = 0; k < values.length; k++) { values[k] = k * 2; }
System.out.print(values);
System.out.print(" " + numbers);
What output is generated by the code fragment below? int[] values = {1, 3, 1, 3, 1}; int[] numbers = values; for (int k = 0; k < values.length; k++) { values[k] = k * 2; } System.out.print(values); System.out.print(" " + numbers);
Signup and view all the answers