Deck 9: Advanced Array Concepts

Full screen (f)
exit full mode
Question
When working with two-dimensional arrays, the length field holds the number of rows in an array and each row has a length field that holds the number of columns in the row.
Use Space or
up arrow
down arrow
to flip the card.
Question
With a two-dimensional array, the ____ field holds the number of rows in the array.

A) size
B) capacity
C) row
D) length
Question
When using the Arrays.binarySearch() method, it is not necessary for the list to be in order because the binarySearch() method will sort the items when called.
Question
In a(n) ____, you repeatedly compare pairs of items, swapping them if they are out of order, eventually creating a sorted list.

A) range match
B) bubble sort
C) enhanced for loop
D) float sort
Question
The bubble sort is the fastest and most efficient sorting technique.
Question
Swapping two values can be accomplished with two statements.
Question
____ is the process of arranging a series of objects in some logical order.

A) Passing
B) Organizing
C) Sorting
D) Sending
Question
The Arrays class ____ method puts a particular value in each element of the array.

A) binarySearch
B) fill
C) equals
D) search
Question
When using an insertion sort, each list element is examined one at a time and moved down if the tested element should be inserted before them.
Question
How would you create an array named someNumbers that holds three rows and four columns?

A) int[][] someNumbers = new int[4][3];
B) int[][] someNumbers = new int[3][4];
C) int[] someNumbers = new int[3][4];
D) double[][] someNumbers = new int[3][4];
Question
Which Java statement creates a jagged array with six rows?

A) double [][] sales = new double[6][4]
B) double [][] sales = new double[4][6]
C) double [][] sales = new double[6][]
D) double [][] sales = new double[][6]
Question
When you pass a two-dimensional array to a method, you pass the array name just as you do with a one-dimensional array.
Question
You can think of the single dimension of a single dimensional array as the height of the array.
Question
The Arrays class ____ methods are a new feature in Java 8 that makes sorting more efficient when thousands or millions of objects need to be sorted.

A) compare
B) equals
C) parallelSort
D) fill
Question
When mathematicians use a two-dimensional array, they often call it a ____.

A) grid
B) net
C) matrix
D) mesh
Question
If you do not provide values for the elements in a two-dimensional numeric array, the values default to null .
Question
An array that you can picture as a column of values, and whose elements you can access using one subscript, is a ____ array.

A) single-dimensional
B) two-dimensional
C) parallel
D) column
Question
To declare a two-dimensional array in Java, you type two sets of ____ after the array type.

A) { }
B) [ ]
C) ( )
D) < >
Question
The simplest possible sort involves two values that are out of order.
Question
Since the ArrayList class is part of the java.util package, you can use the java.util.*; import statement to access it.
Question
int[][] myVals = {{2, 4, 6},                   {1, 8, 9},
                  {1, 3, 5, 7}};
Using the above array, what is the value of myVals[1].length ?

A) 1
B) 7
C) 3
D) 6
Question
The ArrayList class ____ method returns the current ArrayList size.

A) size
B) capacity
C) length
D) rows
Question
The ArrayList class ____ method removes an item from an ArrayList at a specified location.

A) delete
B) get
C) erase
D) remove
Question
The ArrayList class ____ method retrieves an item from a specified location in an ArrayList .

A) extract
B) get
C) peek
D) retrieve
Question
int[][] myVals = {{2, 4, 6, 8},                   {20, 40, 60, 80} };
Using the above two-dimensional array, what is the value of myVals[1][2] ?

A) 4
B) 60
C) 6
D) 40
Question
When you place objects in order beginning with the object that has the lowest value, you are sorting in ____ order.

A) ascending
B) reverse
C) descending
D) lowest
Question
Regarding enumerations, the ____ method returns the name of the calling constant object.

A) toString
B) constName
C) ordinal
D) nameOf
Question
int[][] myVals = {{2, 4, 6},                   {1, 3, 5, 7}};
Using the above array, what is the value of myVals.length ?

A) 1
B) 2
C) 4
D) 5
Question
A method that receives a two-dimensional array uses two ____ pairs following the data type in the parameter list of the method header.

A) curly brace
B) parenthesis
C) bracket
D) dot
Question
You can add an item at any point in a(n) ____ container and the array size expands automatically to accommodate the new item.

A) ArrayList
B) Array
C) ResizableArray
D) array
Question
In Java, you create an enumerated data type in a statement that uses the keyword ____.

A) new
B) sequence
C) collection
D) enum
Question
Regarding enumerations, the ____ method returns an integer that represents the constant's position in the list of constants; as with arrays, the first position is 0.

A) valueAt
B) positionOf
C) ordinal
D) indexOf
Question
When you place objects in order beginning with the object that has the highest value, you are sorting in ____ order.

A) ascending
B) reverse
C) descending
D) lowest
Question
Which of the following describes a data type for which only appropriate behaviors are allowed?

A) value-neutral
B) type-safe
C) static
D) data-cast
Question
The  Arrays  class ____ method assigns the specified value to each element of the specified array.

A) assign()
B) init()
C) sort()
D) fill()
Question
Programmers often refer to a ____ search as a "divide and conquer" procedure.

A) bubble
B) binary
C) division
D) split
Question
An ArrayList 's ____ is the number of items it can hold without having to increase its size.

A) length
B) buffer
C) capacity
D) size
Question
The  Arrays  class ____ method sorts the specified array into ascending order.

A) assign()
B) init()
C) sort()
D) fill()
Question
The negative integer returned by the binarySearch() method when the value is not found is the negative equivalent of the array ____.

A) type
B) scope
C) size
D) length
Question
double[][] empSales = new double[5][]; The above statement declares a(n) ____ array.

A) insertion
B) sort
C) jagged
D) boolean
Question
Match between columns
A programmer-created data type with a fixed set of values
jagged array
A programmer-created data type with a fixed set of values
bubble sort
A programmer-created data type with a fixed set of values
static methods
A programmer-created data type with a fixed set of values
two-dimensional array
A programmer-created data type with a fixed set of values
add() method
A programmer-created data type with a fixed set of values
Enumerated data type
A programmer-created data type with a fixed set of values
set() method
A programmer-created data type with a fixed set of values
multidimensional array
A programmer-created data type with a fixed set of values
java.util
A programmer-created data type with a fixed set of values
ascending order
A programmer-created data type with a fixed set of values
fill() method
A programmer-created data type with a fixed set of values
matrix
A programmer-created data type with a fixed set of values
dynamically resizable
A programmer-created data type with a fixed set of values
type-safe
A programmer-created data type with a fixed set of values
one-dimensional array
Question
Match between columns
Two or more columns of values
jagged array
Two or more columns of values
bubble sort
Two or more columns of values
static methods
Two or more columns of values
two-dimensional array
Two or more columns of values
add() method
Two or more columns of values
Enumerated data type
Two or more columns of values
set() method
Two or more columns of values
multidimensional array
Two or more columns of values
java.util
Two or more columns of values
ascending order
Two or more columns of values
fill() method
Two or more columns of values
matrix
Two or more columns of values
dynamically resizable
Two or more columns of values
type-safe
Two or more columns of values
one-dimensional array
Question
Match between columns
A package containing the Arrays class
jagged array
A package containing the Arrays class
bubble sort
A package containing the Arrays class
static methods
A package containing the Arrays class
two-dimensional array
A package containing the Arrays class
add() method
A package containing the Arrays class
Enumerated data type
A package containing the Arrays class
set() method
A package containing the Arrays class
multidimensional array
A package containing the Arrays class
java.util
A package containing the Arrays class
ascending order
A package containing the Arrays class
fill() method
A package containing the Arrays class
matrix
A package containing the Arrays class
dynamically resizable
A package containing the Arrays class
type-safe
A package containing the Arrays class
one-dimensional array
Question
Match between columns
A popularly known sorting method
jagged array
A popularly known sorting method
bubble sort
A popularly known sorting method
static methods
A popularly known sorting method
two-dimensional array
A popularly known sorting method
add() method
A popularly known sorting method
Enumerated data type
A popularly known sorting method
set() method
A popularly known sorting method
multidimensional array
A popularly known sorting method
java.util
A popularly known sorting method
ascending order
A popularly known sorting method
fill() method
A popularly known sorting method
matrix
A popularly known sorting method
dynamically resizable
A popularly known sorting method
type-safe
A popularly known sorting method
one-dimensional array
Question
Match between columns
A two-dimensional array that has rows of different lengths
jagged array
A two-dimensional array that has rows of different lengths
bubble sort
A two-dimensional array that has rows of different lengths
static methods
A two-dimensional array that has rows of different lengths
two-dimensional array
A two-dimensional array that has rows of different lengths
add() method
A two-dimensional array that has rows of different lengths
Enumerated data type
A two-dimensional array that has rows of different lengths
set() method
A two-dimensional array that has rows of different lengths
multidimensional array
A two-dimensional array that has rows of different lengths
java.util
A two-dimensional array that has rows of different lengths
ascending order
A two-dimensional array that has rows of different lengths
fill() method
A two-dimensional array that has rows of different lengths
matrix
A two-dimensional array that has rows of different lengths
dynamically resizable
A two-dimensional array that has rows of different lengths
type-safe
A two-dimensional array that has rows of different lengths
one-dimensional array
Question
Match between columns
Can be pictured as a column of values
jagged array
Can be pictured as a column of values
bubble sort
Can be pictured as a column of values
static methods
Can be pictured as a column of values
two-dimensional array
Can be pictured as a column of values
add() method
Can be pictured as a column of values
Enumerated data type
Can be pictured as a column of values
set() method
Can be pictured as a column of values
multidimensional array
Can be pictured as a column of values
java.util
Can be pictured as a column of values
ascending order
Can be pictured as a column of values
fill() method
Can be pictured as a column of values
matrix
Can be pictured as a column of values
dynamically resizable
Can be pictured as a column of values
type-safe
Can be pictured as a column of values
one-dimensional array
Question
Match between columns
Arrays with more than one dimension
jagged array
Arrays with more than one dimension
bubble sort
Arrays with more than one dimension
static methods
Arrays with more than one dimension
two-dimensional array
Arrays with more than one dimension
add() method
Arrays with more than one dimension
Enumerated data type
Arrays with more than one dimension
set() method
Arrays with more than one dimension
multidimensional array
Arrays with more than one dimension
java.util
Arrays with more than one dimension
ascending order
Arrays with more than one dimension
fill() method
Arrays with more than one dimension
matrix
Arrays with more than one dimension
dynamically resizable
Arrays with more than one dimension
type-safe
Arrays with more than one dimension
one-dimensional array
Question
Match between columns
The size can change during program execution
jagged array
The size can change during program execution
bubble sort
The size can change during program execution
static methods
The size can change during program execution
two-dimensional array
The size can change during program execution
add() method
The size can change during program execution
Enumerated data type
The size can change during program execution
set() method
The size can change during program execution
multidimensional array
The size can change during program execution
java.util
The size can change during program execution
ascending order
The size can change during program execution
fill() method
The size can change during program execution
matrix
The size can change during program execution
dynamically resizable
The size can change during program execution
type-safe
The size can change during program execution
one-dimensional array
Question
Match between columns
Adds an item to the end of an ArrayList
jagged array
Adds an item to the end of an ArrayList
bubble sort
Adds an item to the end of an ArrayList
static methods
Adds an item to the end of an ArrayList
two-dimensional array
Adds an item to the end of an ArrayList
add() method
Adds an item to the end of an ArrayList
Enumerated data type
Adds an item to the end of an ArrayList
set() method
Adds an item to the end of an ArrayList
multidimensional array
Adds an item to the end of an ArrayList
java.util
Adds an item to the end of an ArrayList
ascending order
Adds an item to the end of an ArrayList
fill() method
Adds an item to the end of an ArrayList
matrix
Adds an item to the end of an ArrayList
dynamically resizable
Adds an item to the end of an ArrayList
type-safe
Adds an item to the end of an ArrayList
one-dimensional array
Question
How can you sort arrays of objects?
Question
Write the code for bubble sorting a someNums array of integers.
Question
Match between columns
A data type for which only appropriate behaviors are allowed.
jagged array
A data type for which only appropriate behaviors are allowed.
bubble sort
A data type for which only appropriate behaviors are allowed.
static methods
A data type for which only appropriate behaviors are allowed.
two-dimensional array
A data type for which only appropriate behaviors are allowed.
add() method
A data type for which only appropriate behaviors are allowed.
Enumerated data type
A data type for which only appropriate behaviors are allowed.
set() method
A data type for which only appropriate behaviors are allowed.
multidimensional array
A data type for which only appropriate behaviors are allowed.
java.util
A data type for which only appropriate behaviors are allowed.
ascending order
A data type for which only appropriate behaviors are allowed.
fill() method
A data type for which only appropriate behaviors are allowed.
matrix
A data type for which only appropriate behaviors are allowed.
dynamically resizable
A data type for which only appropriate behaviors are allowed.
type-safe
A data type for which only appropriate behaviors are allowed.
one-dimensional array
Question
Match between columns
Two-dimensional array
jagged array
Two-dimensional array
bubble sort
Two-dimensional array
static methods
Two-dimensional array
two-dimensional array
Two-dimensional array
add() method
Two-dimensional array
Enumerated data type
Two-dimensional array
set() method
Two-dimensional array
multidimensional array
Two-dimensional array
java.util
Two-dimensional array
ascending order
Two-dimensional array
fill() method
Two-dimensional array
matrix
Two-dimensional array
dynamically resizable
Two-dimensional array
type-safe
Two-dimensional array
one-dimensional array
Question
Match between columns
Assigns the specified value to each element of the specified array
jagged array
Assigns the specified value to each element of the specified array
bubble sort
Assigns the specified value to each element of the specified array
static methods
Assigns the specified value to each element of the specified array
two-dimensional array
Assigns the specified value to each element of the specified array
add() method
Assigns the specified value to each element of the specified array
Enumerated data type
Assigns the specified value to each element of the specified array
set() method
Assigns the specified value to each element of the specified array
multidimensional array
Assigns the specified value to each element of the specified array
java.util
Assigns the specified value to each element of the specified array
ascending order
Assigns the specified value to each element of the specified array
fill() method
Assigns the specified value to each element of the specified array
matrix
Assigns the specified value to each element of the specified array
dynamically resizable
Assigns the specified value to each element of the specified array
type-safe
Assigns the specified value to each element of the specified array
one-dimensional array
Question
How can you pass a two-dimensional array to a method? Provide some examples.
Question
What is sorting and how are objects organized as a result of being sorted?
Question
Match between columns
Alters an item at a specified ArrayList location
jagged array
Alters an item at a specified ArrayList location
bubble sort
Alters an item at a specified ArrayList location
static methods
Alters an item at a specified ArrayList location
two-dimensional array
Alters an item at a specified ArrayList location
add() method
Alters an item at a specified ArrayList location
Enumerated data type
Alters an item at a specified ArrayList location
set() method
Alters an item at a specified ArrayList location
multidimensional array
Alters an item at a specified ArrayList location
java.util
Alters an item at a specified ArrayList location
ascending order
Alters an item at a specified ArrayList location
fill() method
Alters an item at a specified ArrayList location
matrix
Alters an item at a specified ArrayList location
dynamically resizable
Alters an item at a specified ArrayList location
type-safe
Alters an item at a specified ArrayList location
one-dimensional array
Question
Describe how to visualize the following array. How would you identify the location of the 99 that is stored in the array?
int[][] someNumbers = {{8, 9, 10, 11},
{1, 3, 12, 15},
{5, 9, 44, 99} };
Question
Match between columns
Placing objects in order beginning with the lowest value
jagged array
Placing objects in order beginning with the lowest value
bubble sort
Placing objects in order beginning with the lowest value
static methods
Placing objects in order beginning with the lowest value
two-dimensional array
Placing objects in order beginning with the lowest value
add() method
Placing objects in order beginning with the lowest value
Enumerated data type
Placing objects in order beginning with the lowest value
set() method
Placing objects in order beginning with the lowest value
multidimensional array
Placing objects in order beginning with the lowest value
java.util
Placing objects in order beginning with the lowest value
ascending order
Placing objects in order beginning with the lowest value
fill() method
Placing objects in order beginning with the lowest value
matrix
Placing objects in order beginning with the lowest value
dynamically resizable
Placing objects in order beginning with the lowest value
type-safe
Placing objects in order beginning with the lowest value
one-dimensional array
Question
Match between columns
Use them with the class name without instantiating an object
jagged array
Use them with the class name without instantiating an object
bubble sort
Use them with the class name without instantiating an object
static methods
Use them with the class name without instantiating an object
two-dimensional array
Use them with the class name without instantiating an object
add() method
Use them with the class name without instantiating an object
Enumerated data type
Use them with the class name without instantiating an object
set() method
Use them with the class name without instantiating an object
multidimensional array
Use them with the class name without instantiating an object
java.util
Use them with the class name without instantiating an object
ascending order
Use them with the class name without instantiating an object
fill() method
Use them with the class name without instantiating an object
matrix
Use them with the class name without instantiating an object
dynamically resizable
Use them with the class name without instantiating an object
type-safe
Use them with the class name without instantiating an object
one-dimensional array
Question
What import statements must be used before you can use an ArrayList class?
Question
public class EnumExample
{
    enum Day {SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
              THURSDAY, FRIDAY, SATURDAY };

    Day day;

    public EnumExample(Day day)
    {
        this.day = day;
    }

    public void giveFeedback()
    {
        switch (day)
        {
            case MONDAY:
                System.out.println("Mondays are bad.");
                break;

            case FRIDAY:
                System.out.println("Fridays are better.");
                break;

            case SATURDAY: case SUNDAY:
                System.out.println("Weekends are best.");
                break;

            default:
                System.out.println("Midweek days are so-so.");
                break;
        }
     }

    public static void main(String[] args)
    {
        EnumExample firstDay = new EnumExample(Day.MONDAY);
        firstDay.giveFeedback();
        EnumExample thirdDay = new EnumExample(Day.WEDNESDAY);
        thirdDay.giveFeedback();
        EnumExample fifthDay = new EnumExample(Day.FRIDAY);
        fifthDay.giveFeedback();
        EnumExample sixthDay = new EnumExample(Day.SATURDAY);
        sixthDay.giveFeedback();
        EnumExample seventhDay = new EnumExample(Day.SUNDAY);
        seventhDay.giveFeedback();
    }
}
Using the above enumeration and code, what will be the output when the program is executed?
Question
What are some of the advantages of creating an enumeration type?
Question
Using the ArrayList add() method, write the statement to insert "July" in the first position of the months ArrayList . Describe what would happen if the position number is invalid for the ArrayList .
Question
Write the statement to declare an ArrayList named myVals with a capacity of 15 items. Explain the importance of capacity when working with an ArrayList .
Question
int[][] studentScores = {{70, 82, 90, 68},
{95, 75, 67, 89},
{98, 79, 57, 81}};
Using the above two-dimensional array, what is the value of studentScores[0][0] ? What is the value of studentScores[2][3] ? What is the value of studentScores[1][2] ? Describe how arrays reference values with subscripts.
Question
import javax.swing.*;
class FindPoints
{
   public static void main(String[] args)
   {
      int[][] points =
     {{10, 20, 30},
      {20, 40, 60},
      {40, 60, 80}};
      String prompt;
      int class;
      int level;
      prompt = JOptionPane.showInputDialog(null, "Class: ");
      class = Integer.parseInt(prompt);
      prompt = JOptionPane.showInputDialog(null, "Level: ");
      level = Integer.parseInt(prompt);
      JOption.showMessageDialog(null, "Your points: " + ---complete code here-----);
   }
}
The above code depicts a two-dimensional array named points that refers to a Class and Level to determine a point value. Complete the JOption command so that the code will determine a point value based on the points array.
Question
​import javax.swing.*;
class FindPoints
{
   public static void main(String[] args)
   {
      int[][] points =
     {{10, 20, 30},
      {20, 40, 60},
      {40, 60, 80}};
      String prompt;
      int class;
      int level;
      prompt = JOptionPane.showInputDialog(null, "Class: ");
      class = Integer.parseInt(prompt);
      prompt = JOptionPane.showInputDialog(null, "Level: ");
      level = Integer.parseInt(prompt);

      JOption.showMessageDialog(null, "Your points: " + points[class][level]);
   }
}
The above code depicts a two-dimensional array named points that refers to a Class and Level to determine a point value. If a user inputs a Class of 1 and a Level of 2, what point value will be displayed when the program executes? Explain how you arrived at your answer.
Question
import java.util.*;
public class myArray
{
    public static void main(String[] args)
    {
      int myVals = new int[4];
      -----Code here-----
      display("My values are: ", myVals);
    }
    public static void display(String message, int array[])
    {
       int arraySize = array.length;
       System.out.print(message);
       for(int x = 0; x < arraySize; ++x)
          System.out.print(array[x] + " ");
    }
}
Using the above code, complete the indicated section with a fill method() to fill each array element with a value of 2. What will be displayed after the display() method is executed?
Question
How can you use the length field with a two-dimensional array? Show an example two-dimensional array declaration and provide the length values for the example array.
Question
int[][] myVals = {{10, 15, 20, 25},
                  {30, 35, 40, 45, 50, 55, 60},
                  {65, 70, 75, 80, 85, 90}};
Using the above array, what is the value of myVals.length ? What is the value of myVals[1].length ? What is the value of myVals[2].length ? Explain how you determined these values.
Question
What are some of the advantages of the ArrayList class over the Arrays class?
Question
Declare an ArrayList that declares a list of strings with a capacity of 20.
Question
int[][] myVals = new int[3][]
myVals[0] = new int[3];
myVals[1] = new int[10];
myVals[2] = new int[5];
The above code depicts a jagged array. What does this mean? Describe the rows and columns that make up this array.
Question
What is the advantage of declaring an ArrayList with a specified type?
Question
import java.util.*;
public class sortArray
{
     public static void main(String[] args)
    {
       double[] lengths = {120.0, 0.5, 0.0, 999.0, 77.3};
       Arrays.sort(lengths);
         System.out.println(Arrays.toString(lengths));
    }
}
Using the above code, what will be the output of the println statement when the code is executed?
Question
import java.util.*;
import javax.swing.*;
public class binary_search
{
    public static void main(String[] args)
   {
           int myNums[]={2, 44, 5, 66, 78, 90, 23, 66};
           int point, find = 78;
           point = Arrays.binarySearch(myNums, find);
           System.out.println("Element found at index " + point);
  
    }
}
Using the above code, what output will be displayed when the program is executed? Describe how the binarySearch() method functions.
Question
Write the statement that assigns the integer value 20 to the first column of the first row of an array named myVals .
Question
Write the statement to declare a three-by-four array of integers with the elements initialized to zero. Name the array myArray .
Question
enum Color {RED, GREEN, BLUE}
public class EnumOrdinal
{
    public static void main(String[] args)
   {
     ---Code here---
     ---Code here---
     ---Code here---
    }
}
The above code demonstrates the use of the enum ordinal() method to get the ordinal value of an enum constant. Fill in the indicated lines with println() statements that will get the ordinal of the enumeration constant. Describe the output that will display when the code is executed.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/80
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 9: Advanced Array Concepts
1
When working with two-dimensional arrays, the length field holds the number of rows in an array and each row has a length field that holds the number of columns in the row.
True
2
With a two-dimensional array, the ____ field holds the number of rows in the array.

A) size
B) capacity
C) row
D) length
D
3
When using the Arrays.binarySearch() method, it is not necessary for the list to be in order because the binarySearch() method will sort the items when called.
False
4
In a(n) ____, you repeatedly compare pairs of items, swapping them if they are out of order, eventually creating a sorted list.

A) range match
B) bubble sort
C) enhanced for loop
D) float sort
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
5
The bubble sort is the fastest and most efficient sorting technique.
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
6
Swapping two values can be accomplished with two statements.
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
7
____ is the process of arranging a series of objects in some logical order.

A) Passing
B) Organizing
C) Sorting
D) Sending
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
8
The Arrays class ____ method puts a particular value in each element of the array.

A) binarySearch
B) fill
C) equals
D) search
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
9
When using an insertion sort, each list element is examined one at a time and moved down if the tested element should be inserted before them.
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
10
How would you create an array named someNumbers that holds three rows and four columns?

A) int[][] someNumbers = new int[4][3];
B) int[][] someNumbers = new int[3][4];
C) int[] someNumbers = new int[3][4];
D) double[][] someNumbers = new int[3][4];
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
11
Which Java statement creates a jagged array with six rows?

A) double [][] sales = new double[6][4]
B) double [][] sales = new double[4][6]
C) double [][] sales = new double[6][]
D) double [][] sales = new double[][6]
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
12
When you pass a two-dimensional array to a method, you pass the array name just as you do with a one-dimensional array.
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
13
You can think of the single dimension of a single dimensional array as the height of the array.
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
14
The Arrays class ____ methods are a new feature in Java 8 that makes sorting more efficient when thousands or millions of objects need to be sorted.

A) compare
B) equals
C) parallelSort
D) fill
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
15
When mathematicians use a two-dimensional array, they often call it a ____.

A) grid
B) net
C) matrix
D) mesh
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
16
If you do not provide values for the elements in a two-dimensional numeric array, the values default to null .
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
17
An array that you can picture as a column of values, and whose elements you can access using one subscript, is a ____ array.

A) single-dimensional
B) two-dimensional
C) parallel
D) column
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
18
To declare a two-dimensional array in Java, you type two sets of ____ after the array type.

A) { }
B) [ ]
C) ( )
D) < >
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
19
The simplest possible sort involves two values that are out of order.
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
20
Since the ArrayList class is part of the java.util package, you can use the java.util.*; import statement to access it.
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
21
int[][] myVals = {{2, 4, 6},                   {1, 8, 9},
                  {1, 3, 5, 7}};
Using the above array, what is the value of myVals[1].length ?

A) 1
B) 7
C) 3
D) 6
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
22
The ArrayList class ____ method returns the current ArrayList size.

A) size
B) capacity
C) length
D) rows
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
23
The ArrayList class ____ method removes an item from an ArrayList at a specified location.

A) delete
B) get
C) erase
D) remove
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
24
The ArrayList class ____ method retrieves an item from a specified location in an ArrayList .

A) extract
B) get
C) peek
D) retrieve
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
25
int[][] myVals = {{2, 4, 6, 8},                   {20, 40, 60, 80} };
Using the above two-dimensional array, what is the value of myVals[1][2] ?

A) 4
B) 60
C) 6
D) 40
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
26
When you place objects in order beginning with the object that has the lowest value, you are sorting in ____ order.

A) ascending
B) reverse
C) descending
D) lowest
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
27
Regarding enumerations, the ____ method returns the name of the calling constant object.

A) toString
B) constName
C) ordinal
D) nameOf
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
28
int[][] myVals = {{2, 4, 6},                   {1, 3, 5, 7}};
Using the above array, what is the value of myVals.length ?

A) 1
B) 2
C) 4
D) 5
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
29
A method that receives a two-dimensional array uses two ____ pairs following the data type in the parameter list of the method header.

A) curly brace
B) parenthesis
C) bracket
D) dot
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
30
You can add an item at any point in a(n) ____ container and the array size expands automatically to accommodate the new item.

A) ArrayList
B) Array
C) ResizableArray
D) array
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
31
In Java, you create an enumerated data type in a statement that uses the keyword ____.

A) new
B) sequence
C) collection
D) enum
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
32
Regarding enumerations, the ____ method returns an integer that represents the constant's position in the list of constants; as with arrays, the first position is 0.

A) valueAt
B) positionOf
C) ordinal
D) indexOf
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
33
When you place objects in order beginning with the object that has the highest value, you are sorting in ____ order.

A) ascending
B) reverse
C) descending
D) lowest
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
34
Which of the following describes a data type for which only appropriate behaviors are allowed?

A) value-neutral
B) type-safe
C) static
D) data-cast
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
35
The  Arrays  class ____ method assigns the specified value to each element of the specified array.

A) assign()
B) init()
C) sort()
D) fill()
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
36
Programmers often refer to a ____ search as a "divide and conquer" procedure.

A) bubble
B) binary
C) division
D) split
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
37
An ArrayList 's ____ is the number of items it can hold without having to increase its size.

A) length
B) buffer
C) capacity
D) size
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
38
The  Arrays  class ____ method sorts the specified array into ascending order.

A) assign()
B) init()
C) sort()
D) fill()
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
39
The negative integer returned by the binarySearch() method when the value is not found is the negative equivalent of the array ____.

A) type
B) scope
C) size
D) length
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
40
double[][] empSales = new double[5][]; The above statement declares a(n) ____ array.

A) insertion
B) sort
C) jagged
D) boolean
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
41
Match between columns
A programmer-created data type with a fixed set of values
jagged array
A programmer-created data type with a fixed set of values
bubble sort
A programmer-created data type with a fixed set of values
static methods
A programmer-created data type with a fixed set of values
two-dimensional array
A programmer-created data type with a fixed set of values
add() method
A programmer-created data type with a fixed set of values
Enumerated data type
A programmer-created data type with a fixed set of values
set() method
A programmer-created data type with a fixed set of values
multidimensional array
A programmer-created data type with a fixed set of values
java.util
A programmer-created data type with a fixed set of values
ascending order
A programmer-created data type with a fixed set of values
fill() method
A programmer-created data type with a fixed set of values
matrix
A programmer-created data type with a fixed set of values
dynamically resizable
A programmer-created data type with a fixed set of values
type-safe
A programmer-created data type with a fixed set of values
one-dimensional array
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
42
Match between columns
Two or more columns of values
jagged array
Two or more columns of values
bubble sort
Two or more columns of values
static methods
Two or more columns of values
two-dimensional array
Two or more columns of values
add() method
Two or more columns of values
Enumerated data type
Two or more columns of values
set() method
Two or more columns of values
multidimensional array
Two or more columns of values
java.util
Two or more columns of values
ascending order
Two or more columns of values
fill() method
Two or more columns of values
matrix
Two or more columns of values
dynamically resizable
Two or more columns of values
type-safe
Two or more columns of values
one-dimensional array
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
43
Match between columns
A package containing the Arrays class
jagged array
A package containing the Arrays class
bubble sort
A package containing the Arrays class
static methods
A package containing the Arrays class
two-dimensional array
A package containing the Arrays class
add() method
A package containing the Arrays class
Enumerated data type
A package containing the Arrays class
set() method
A package containing the Arrays class
multidimensional array
A package containing the Arrays class
java.util
A package containing the Arrays class
ascending order
A package containing the Arrays class
fill() method
A package containing the Arrays class
matrix
A package containing the Arrays class
dynamically resizable
A package containing the Arrays class
type-safe
A package containing the Arrays class
one-dimensional array
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
44
Match between columns
A popularly known sorting method
jagged array
A popularly known sorting method
bubble sort
A popularly known sorting method
static methods
A popularly known sorting method
two-dimensional array
A popularly known sorting method
add() method
A popularly known sorting method
Enumerated data type
A popularly known sorting method
set() method
A popularly known sorting method
multidimensional array
A popularly known sorting method
java.util
A popularly known sorting method
ascending order
A popularly known sorting method
fill() method
A popularly known sorting method
matrix
A popularly known sorting method
dynamically resizable
A popularly known sorting method
type-safe
A popularly known sorting method
one-dimensional array
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
45
Match between columns
A two-dimensional array that has rows of different lengths
jagged array
A two-dimensional array that has rows of different lengths
bubble sort
A two-dimensional array that has rows of different lengths
static methods
A two-dimensional array that has rows of different lengths
two-dimensional array
A two-dimensional array that has rows of different lengths
add() method
A two-dimensional array that has rows of different lengths
Enumerated data type
A two-dimensional array that has rows of different lengths
set() method
A two-dimensional array that has rows of different lengths
multidimensional array
A two-dimensional array that has rows of different lengths
java.util
A two-dimensional array that has rows of different lengths
ascending order
A two-dimensional array that has rows of different lengths
fill() method
A two-dimensional array that has rows of different lengths
matrix
A two-dimensional array that has rows of different lengths
dynamically resizable
A two-dimensional array that has rows of different lengths
type-safe
A two-dimensional array that has rows of different lengths
one-dimensional array
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
46
Match between columns
Can be pictured as a column of values
jagged array
Can be pictured as a column of values
bubble sort
Can be pictured as a column of values
static methods
Can be pictured as a column of values
two-dimensional array
Can be pictured as a column of values
add() method
Can be pictured as a column of values
Enumerated data type
Can be pictured as a column of values
set() method
Can be pictured as a column of values
multidimensional array
Can be pictured as a column of values
java.util
Can be pictured as a column of values
ascending order
Can be pictured as a column of values
fill() method
Can be pictured as a column of values
matrix
Can be pictured as a column of values
dynamically resizable
Can be pictured as a column of values
type-safe
Can be pictured as a column of values
one-dimensional array
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
47
Match between columns
Arrays with more than one dimension
jagged array
Arrays with more than one dimension
bubble sort
Arrays with more than one dimension
static methods
Arrays with more than one dimension
two-dimensional array
Arrays with more than one dimension
add() method
Arrays with more than one dimension
Enumerated data type
Arrays with more than one dimension
set() method
Arrays with more than one dimension
multidimensional array
Arrays with more than one dimension
java.util
Arrays with more than one dimension
ascending order
Arrays with more than one dimension
fill() method
Arrays with more than one dimension
matrix
Arrays with more than one dimension
dynamically resizable
Arrays with more than one dimension
type-safe
Arrays with more than one dimension
one-dimensional array
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
48
Match between columns
The size can change during program execution
jagged array
The size can change during program execution
bubble sort
The size can change during program execution
static methods
The size can change during program execution
two-dimensional array
The size can change during program execution
add() method
The size can change during program execution
Enumerated data type
The size can change during program execution
set() method
The size can change during program execution
multidimensional array
The size can change during program execution
java.util
The size can change during program execution
ascending order
The size can change during program execution
fill() method
The size can change during program execution
matrix
The size can change during program execution
dynamically resizable
The size can change during program execution
type-safe
The size can change during program execution
one-dimensional array
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
49
Match between columns
Adds an item to the end of an ArrayList
jagged array
Adds an item to the end of an ArrayList
bubble sort
Adds an item to the end of an ArrayList
static methods
Adds an item to the end of an ArrayList
two-dimensional array
Adds an item to the end of an ArrayList
add() method
Adds an item to the end of an ArrayList
Enumerated data type
Adds an item to the end of an ArrayList
set() method
Adds an item to the end of an ArrayList
multidimensional array
Adds an item to the end of an ArrayList
java.util
Adds an item to the end of an ArrayList
ascending order
Adds an item to the end of an ArrayList
fill() method
Adds an item to the end of an ArrayList
matrix
Adds an item to the end of an ArrayList
dynamically resizable
Adds an item to the end of an ArrayList
type-safe
Adds an item to the end of an ArrayList
one-dimensional array
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
50
How can you sort arrays of objects?
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
51
Write the code for bubble sorting a someNums array of integers.
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
52
Match between columns
A data type for which only appropriate behaviors are allowed.
jagged array
A data type for which only appropriate behaviors are allowed.
bubble sort
A data type for which only appropriate behaviors are allowed.
static methods
A data type for which only appropriate behaviors are allowed.
two-dimensional array
A data type for which only appropriate behaviors are allowed.
add() method
A data type for which only appropriate behaviors are allowed.
Enumerated data type
A data type for which only appropriate behaviors are allowed.
set() method
A data type for which only appropriate behaviors are allowed.
multidimensional array
A data type for which only appropriate behaviors are allowed.
java.util
A data type for which only appropriate behaviors are allowed.
ascending order
A data type for which only appropriate behaviors are allowed.
fill() method
A data type for which only appropriate behaviors are allowed.
matrix
A data type for which only appropriate behaviors are allowed.
dynamically resizable
A data type for which only appropriate behaviors are allowed.
type-safe
A data type for which only appropriate behaviors are allowed.
one-dimensional array
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
53
Match between columns
Two-dimensional array
jagged array
Two-dimensional array
bubble sort
Two-dimensional array
static methods
Two-dimensional array
two-dimensional array
Two-dimensional array
add() method
Two-dimensional array
Enumerated data type
Two-dimensional array
set() method
Two-dimensional array
multidimensional array
Two-dimensional array
java.util
Two-dimensional array
ascending order
Two-dimensional array
fill() method
Two-dimensional array
matrix
Two-dimensional array
dynamically resizable
Two-dimensional array
type-safe
Two-dimensional array
one-dimensional array
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
54
Match between columns
Assigns the specified value to each element of the specified array
jagged array
Assigns the specified value to each element of the specified array
bubble sort
Assigns the specified value to each element of the specified array
static methods
Assigns the specified value to each element of the specified array
two-dimensional array
Assigns the specified value to each element of the specified array
add() method
Assigns the specified value to each element of the specified array
Enumerated data type
Assigns the specified value to each element of the specified array
set() method
Assigns the specified value to each element of the specified array
multidimensional array
Assigns the specified value to each element of the specified array
java.util
Assigns the specified value to each element of the specified array
ascending order
Assigns the specified value to each element of the specified array
fill() method
Assigns the specified value to each element of the specified array
matrix
Assigns the specified value to each element of the specified array
dynamically resizable
Assigns the specified value to each element of the specified array
type-safe
Assigns the specified value to each element of the specified array
one-dimensional array
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
55
How can you pass a two-dimensional array to a method? Provide some examples.
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
56
What is sorting and how are objects organized as a result of being sorted?
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
57
Match between columns
Alters an item at a specified ArrayList location
jagged array
Alters an item at a specified ArrayList location
bubble sort
Alters an item at a specified ArrayList location
static methods
Alters an item at a specified ArrayList location
two-dimensional array
Alters an item at a specified ArrayList location
add() method
Alters an item at a specified ArrayList location
Enumerated data type
Alters an item at a specified ArrayList location
set() method
Alters an item at a specified ArrayList location
multidimensional array
Alters an item at a specified ArrayList location
java.util
Alters an item at a specified ArrayList location
ascending order
Alters an item at a specified ArrayList location
fill() method
Alters an item at a specified ArrayList location
matrix
Alters an item at a specified ArrayList location
dynamically resizable
Alters an item at a specified ArrayList location
type-safe
Alters an item at a specified ArrayList location
one-dimensional array
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
58
Describe how to visualize the following array. How would you identify the location of the 99 that is stored in the array?
int[][] someNumbers = {{8, 9, 10, 11},
{1, 3, 12, 15},
{5, 9, 44, 99} };
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
59
Match between columns
Placing objects in order beginning with the lowest value
jagged array
Placing objects in order beginning with the lowest value
bubble sort
Placing objects in order beginning with the lowest value
static methods
Placing objects in order beginning with the lowest value
two-dimensional array
Placing objects in order beginning with the lowest value
add() method
Placing objects in order beginning with the lowest value
Enumerated data type
Placing objects in order beginning with the lowest value
set() method
Placing objects in order beginning with the lowest value
multidimensional array
Placing objects in order beginning with the lowest value
java.util
Placing objects in order beginning with the lowest value
ascending order
Placing objects in order beginning with the lowest value
fill() method
Placing objects in order beginning with the lowest value
matrix
Placing objects in order beginning with the lowest value
dynamically resizable
Placing objects in order beginning with the lowest value
type-safe
Placing objects in order beginning with the lowest value
one-dimensional array
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
60
Match between columns
Use them with the class name without instantiating an object
jagged array
Use them with the class name without instantiating an object
bubble sort
Use them with the class name without instantiating an object
static methods
Use them with the class name without instantiating an object
two-dimensional array
Use them with the class name without instantiating an object
add() method
Use them with the class name without instantiating an object
Enumerated data type
Use them with the class name without instantiating an object
set() method
Use them with the class name without instantiating an object
multidimensional array
Use them with the class name without instantiating an object
java.util
Use them with the class name without instantiating an object
ascending order
Use them with the class name without instantiating an object
fill() method
Use them with the class name without instantiating an object
matrix
Use them with the class name without instantiating an object
dynamically resizable
Use them with the class name without instantiating an object
type-safe
Use them with the class name without instantiating an object
one-dimensional array
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
61
What import statements must be used before you can use an ArrayList class?
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
62
public class EnumExample
{
    enum Day {SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
              THURSDAY, FRIDAY, SATURDAY };

    Day day;

    public EnumExample(Day day)
    {
        this.day = day;
    }

    public void giveFeedback()
    {
        switch (day)
        {
            case MONDAY:
                System.out.println("Mondays are bad.");
                break;

            case FRIDAY:
                System.out.println("Fridays are better.");
                break;

            case SATURDAY: case SUNDAY:
                System.out.println("Weekends are best.");
                break;

            default:
                System.out.println("Midweek days are so-so.");
                break;
        }
     }

    public static void main(String[] args)
    {
        EnumExample firstDay = new EnumExample(Day.MONDAY);
        firstDay.giveFeedback();
        EnumExample thirdDay = new EnumExample(Day.WEDNESDAY);
        thirdDay.giveFeedback();
        EnumExample fifthDay = new EnumExample(Day.FRIDAY);
        fifthDay.giveFeedback();
        EnumExample sixthDay = new EnumExample(Day.SATURDAY);
        sixthDay.giveFeedback();
        EnumExample seventhDay = new EnumExample(Day.SUNDAY);
        seventhDay.giveFeedback();
    }
}
Using the above enumeration and code, what will be the output when the program is executed?
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
63
What are some of the advantages of creating an enumeration type?
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
64
Using the ArrayList add() method, write the statement to insert "July" in the first position of the months ArrayList . Describe what would happen if the position number is invalid for the ArrayList .
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
65
Write the statement to declare an ArrayList named myVals with a capacity of 15 items. Explain the importance of capacity when working with an ArrayList .
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
66
int[][] studentScores = {{70, 82, 90, 68},
{95, 75, 67, 89},
{98, 79, 57, 81}};
Using the above two-dimensional array, what is the value of studentScores[0][0] ? What is the value of studentScores[2][3] ? What is the value of studentScores[1][2] ? Describe how arrays reference values with subscripts.
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
67
import javax.swing.*;
class FindPoints
{
   public static void main(String[] args)
   {
      int[][] points =
     {{10, 20, 30},
      {20, 40, 60},
      {40, 60, 80}};
      String prompt;
      int class;
      int level;
      prompt = JOptionPane.showInputDialog(null, "Class: ");
      class = Integer.parseInt(prompt);
      prompt = JOptionPane.showInputDialog(null, "Level: ");
      level = Integer.parseInt(prompt);
      JOption.showMessageDialog(null, "Your points: " + ---complete code here-----);
   }
}
The above code depicts a two-dimensional array named points that refers to a Class and Level to determine a point value. Complete the JOption command so that the code will determine a point value based on the points array.
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
68
​import javax.swing.*;
class FindPoints
{
   public static void main(String[] args)
   {
      int[][] points =
     {{10, 20, 30},
      {20, 40, 60},
      {40, 60, 80}};
      String prompt;
      int class;
      int level;
      prompt = JOptionPane.showInputDialog(null, "Class: ");
      class = Integer.parseInt(prompt);
      prompt = JOptionPane.showInputDialog(null, "Level: ");
      level = Integer.parseInt(prompt);

      JOption.showMessageDialog(null, "Your points: " + points[class][level]);
   }
}
The above code depicts a two-dimensional array named points that refers to a Class and Level to determine a point value. If a user inputs a Class of 1 and a Level of 2, what point value will be displayed when the program executes? Explain how you arrived at your answer.
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
69
import java.util.*;
public class myArray
{
    public static void main(String[] args)
    {
      int myVals = new int[4];
      -----Code here-----
      display("My values are: ", myVals);
    }
    public static void display(String message, int array[])
    {
       int arraySize = array.length;
       System.out.print(message);
       for(int x = 0; x < arraySize; ++x)
          System.out.print(array[x] + " ");
    }
}
Using the above code, complete the indicated section with a fill method() to fill each array element with a value of 2. What will be displayed after the display() method is executed?
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
70
How can you use the length field with a two-dimensional array? Show an example two-dimensional array declaration and provide the length values for the example array.
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
71
int[][] myVals = {{10, 15, 20, 25},
                  {30, 35, 40, 45, 50, 55, 60},
                  {65, 70, 75, 80, 85, 90}};
Using the above array, what is the value of myVals.length ? What is the value of myVals[1].length ? What is the value of myVals[2].length ? Explain how you determined these values.
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
72
What are some of the advantages of the ArrayList class over the Arrays class?
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
73
Declare an ArrayList that declares a list of strings with a capacity of 20.
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
74
int[][] myVals = new int[3][]
myVals[0] = new int[3];
myVals[1] = new int[10];
myVals[2] = new int[5];
The above code depicts a jagged array. What does this mean? Describe the rows and columns that make up this array.
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
75
What is the advantage of declaring an ArrayList with a specified type?
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
76
import java.util.*;
public class sortArray
{
     public static void main(String[] args)
    {
       double[] lengths = {120.0, 0.5, 0.0, 999.0, 77.3};
       Arrays.sort(lengths);
         System.out.println(Arrays.toString(lengths));
    }
}
Using the above code, what will be the output of the println statement when the code is executed?
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
77
import java.util.*;
import javax.swing.*;
public class binary_search
{
    public static void main(String[] args)
   {
           int myNums[]={2, 44, 5, 66, 78, 90, 23, 66};
           int point, find = 78;
           point = Arrays.binarySearch(myNums, find);
           System.out.println("Element found at index " + point);
  
    }
}
Using the above code, what output will be displayed when the program is executed? Describe how the binarySearch() method functions.
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
78
Write the statement that assigns the integer value 20 to the first column of the first row of an array named myVals .
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
79
Write the statement to declare a three-by-four array of integers with the elements initialized to zero. Name the array myArray .
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
80
enum Color {RED, GREEN, BLUE}
public class EnumOrdinal
{
    public static void main(String[] args)
   {
     ---Code here---
     ---Code here---
     ---Code here---
    }
}
The above code demonstrates the use of the enum ordinal() method to get the ordinal value of an enum constant. Fill in the indicated lines with println() statements that will get the ordinal of the enumeration constant. Describe the output that will display when the code is executed.
Unlock Deck
Unlock for access to all 80 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 80 flashcards in this deck.