Quiz #2
Wednesday
With a piece of paper, write down your name and answers to the following questions.
The index to the last element of an array is:
- 100
- 0
- The length of the array
- One less than the length of the array
This search algorithm repeatedly divides the portion of an array being searched in half:
- Binary Search
- Sequential Search
- Selection Search
- Iterative Search
This type of method cannot access any non-static member variables in its own class.
- instance
- void
- static
- non-static
What is the output of the following program.
public final class Program { public static void main(final String[] args) { final int[] numberArrayOne = new int[] { 1, 2, 3 }; final int[] numberArrayTwo = new int[] { 1, 2, 3 }; if (numberArrayOne == numberArrayTwo) { System.out.println("YES"); } else { System.out.println("NO"); } } }
Answer:
NO
Student Performance and Statistics
A histogram of student performance on percentage grades for Quiz 2 on Wednesday.
A table showing the average performance for each question in Quiz 2 on Wednesday.
Friday
With a piece of paper, write down your name and answers to for following questions.
When initializing a two-dimensional array, you enclose each row's initialization list in:
- Braces
- Parentheses
- Brackets
- Quotation marks
In this sorting algorithm, we look for the smallest element in a unsorted array and put it in the proper place.
- Insertion Sort
- Selection Sort
- Bubble Sort
- Merge Sort
When an object is passed as an argument to a method, what is passed?
- A copy of the object
- The name of the object
- A reference to the object
- None of these; You cannot pass an object to a method
If you write this method for a class, Java will automatically call it when you concatenate an object of this class with a string. What is this method called?
Answer: The
toString
method.Find an error from the following code:
int[] array = new array[10]; for (int i = 0; i <= 10; i++) { array[i] = i; }
Correction:
int[] array = new array[10]; for (int i = 0; i < 10; i++) { array[i] = i; }
Student Performance and Statistics
A histogram of student performance on percentage grades for Quiz 2 on Friday.
A table showing the average performance for each question in Quiz 2 on Friday.