1/16
These flashcards cover key concepts about arrays from Chapter 6 of Java Software Solutions, including definitions, usages, and related programming components.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
What are arrays in Java?
Arrays are objects that help organize large amounts of information in an ordered list.
How is a specific value in an array referenced?
Using the array name followed by the index in brackets, for example, scores[2].
What is the result of the expression scores[2] if the array scores holds the values {79, 87, 94, 82, 67, 98, 87, 81, 74, 91}?
The result is 94.
What is the purpose of bounds checking in arrays?
Bounds checking ensures that an index used in an array reference specifies a valid element (0 to N-1), throwing an ArrayIndexOutOfBoundsException if it does not.
How is an array declared in Java?
An array can be declared with a specific type, e.g., int[] scores = new int[10];.
What is an initializer list in Java?
An initializer list is used to instantiate and initialize an array in one step with values delimited by braces and separated by commas.
What is the difference between passing an entire array and passing an array element as parameter to a method?
Passing an entire array passes the reference to the array, while passing an array element follows the parameter passing rules of the element's type.
What is a selection sort?
Selection Sort is an algorithm that selects the smallest value from a list and places it in the correct order, repeating this process for all values.
What is a binary search?
A binary search is a more efficient search method that can only be performed on an ordered list, examining the middle element and moving left or right based on comparisons.
What is hashing in the context of arrays?
Hashing is a technique used to efficiently store and retrieve data in an array, using a hash function to calculate an index.
What is a two-dimensional array?
A two-dimensional array is an array of arrays, which can be thought of as a table with rows and columns.
What is the ArrayList class in Java?
The ArrayList class is a part of the java.util package that stores a list of values and allows dynamic resizing, unlike traditional arrays.
How do you specify the element type of an ArrayList?
Using generics, e.g., ArrayList
What is the difference in efficiency between selecting and inserting in ArrayLists?
Inserts at the end are efficient, but inserting in the middle requires shifting elements, which may be less efficient.
What defines the Comparable interface in Java?
The Comparable interface allows defining an inherent ordering for objects by implementing the compareTo method.
What is the importance of the length property in arrays?
The length property holds the number of elements in an array, not the largest index.
What is the role of a JCheckBox in Java GUI?
A JCheckBox can be toggled on or off and generates item events when its state changes.