Exam 9: Advanced Array Concepts

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

You can add an item at any point in a(n) ____ container and the array size expands automatically to accommodate the new item.

Free
(Multiple Choice)
4.7/5
(43)
Correct Answer:
Verified

A

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.

Free
(Essay)
4.7/5
(43)
Correct Answer:
Verified

In a two-dimensional array, each row also is an array. In Java, you can declare each row to have a different length. When a two-dimensional array has rows of different lengths, it is a jagged array because you can picture the ends of each row as uneven. You create a jagged array by defining the number of rows for a two-dimensional array, but not defining the number of columns in the rows.
The array is defined as follows:
int[][] myVals = new int[3][]
This statement declares an array with three rows, but the rows are not yet created. Then, the individual rows are declared using the following statements:
myVals[0] = new int[3];
myVals[1] = new int[10];
myVals[2] = new int[5];
myVals[0] has 3 elements/columns.
myVals[1] has 10 elements/columns.
myVals[2] has 5 elements/columns.

An array that you can picture as a column of values, and whose elements you can access using one subscript, is a ____ array.

Free
(Multiple Choice)
4.9/5
(43)
Correct Answer:
Verified

A

What are some of the advantages of the ArrayList class over the Arrays class?

(Essay)
4.8/5
(35)
Match each term with the correct statement below.
Premises:
Assigns the specified value to each element of the specified array
Responses:
jagged array
matrix
set() method
Correct Answer:
Verified
Premises:
Responses:
Assigns the specified value to each element of the specified array
jagged array
(Matching)
4.8/5
(34)

The  Arrays  class ____ method sorts the specified array into ascending order.

(Multiple Choice)
4.8/5
(32)

​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.

(Essay)
4.8/5
(38)

When you place objects in order beginning with the object that has the lowest value, you are sorting in ____ order.

(Multiple Choice)
4.8/5
(32)

With a two-dimensional array, the ____ field holds the number of rows in the array.

(Multiple Choice)
4.8/5
(41)

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.

(Essay)
4.7/5
(33)

How can you pass a two-dimensional array to a method? Provide some examples.

(Essay)
4.8/5
(38)
Match each term with the correct statement below.
Premises:
Adds an item to the end of an ArrayList
Responses:
Enumerated data type
ascending order
matrix
Correct Answer:
Verified
Premises:
Responses:
Adds an item to the end of an ArrayList
Enumerated data type
(Matching)
4.9/5
(37)

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.

(True/False)
4.7/5
(37)

To declare a two-dimensional array in Java, you type two sets of ____ after the array type.

(Multiple Choice)
4.8/5
(37)

Write the statement that assigns the integer value 20 to the first column of the first row of an array named myVals .

(Short Answer)
4.8/5
(46)

What import statements must be used before you can use an ArrayList class?

(Essay)
4.8/5
(35)

If you do not provide values for the elements in a two-dimensional numeric array, the values default to null .

(True/False)
4.7/5
(37)
Match each term with the correct statement below.
Premises:
A programmer-created data type with a fixed set of values
Responses:
type-safe
Enumerated data type
set() method
Correct Answer:
Verified
Premises:
Responses:
A programmer-created data type with a fixed set of values
type-safe
(Matching)
4.8/5
(48)

The Arrays class ____ method puts a particular value in each element of the array.

(Multiple Choice)
4.9/5
(41)

int[][] myVals = {{2, 4, 6},                   {1, 8, 9},                   {1, 3, 5, 7}}; Using the above array, what is the value of myVals[1].length ?

(Multiple Choice)
4.8/5
(39)
Showing 1 - 20 of 80
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)