Exam 9: Advanced Array Concepts

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

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.7/5
(31)

Since the Arrays class is part of the java.util package, you can use the java.util.*; import statement to access it.

(True/False)
4.7/5
(39)

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?

(Essay)
4.9/5
(35)

In a(n) ____, you continue to compare pairs of items, swapping them if they are out of order, so that the smallest items rise to the top of the list, eventually creating a sorted list.

(Multiple Choice)
4.8/5
(32)

Match each term with the correct statement below. -A programmer-created data type with a fixed set of values

(Multiple Choice)
4.8/5
(34)

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,

(Essay)
4.8/5
(38)

import java.util.*; public class myArray { public static void main(String[] args) { int myVals = new int[4]; ____ 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 shaded 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?

(Essay)
4.8/5
(32)

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

(Multiple Choice)
4.9/5
(38)

When you pass a two-dimensional array to a method, you pass the array name just as you do with a one-dimensional array.

(True/False)
4.9/5
(43)

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

(Essay)
5.0/5
(35)

enum Color {RED, GREEN, BLUE} public class EnumOrdinal { public static void main(String[] args) { ____ ____ ____ } } The above code demonstrates the use of the enum ordinal() method to get the ordinal value of an enum constant. Fill in the shaded lines with println() statements that will get the ordinal of the enumeration constant. Describe the output that will display when the code is executed.

(Essay)
4.9/5
(44)

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

(Multiple Choice)
4.8/5
(31)

The Arrays class ____ method searches the specified array for the specified key value using the binary search algorithm.

(Multiple Choice)
4.8/5
(37)

How would you create an array named someNumbers that holds three rows and four columns?

(Multiple Choice)
4.9/5
(31)

double[][] empSales = new double[5][]; The above statement declares a(n) ____ array.

(Multiple Choice)
4.8/5
(36)

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.8/5
(37)

Regarding enumerations, the ____ method returns the name of the calling constant object.

(Multiple Choice)
4.8/5
(32)

The negative integer returned by the binarySearch() method when the value is not found is the negative equivalent of the array ____.

(Multiple Choice)
4.7/5
(46)

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} };

(Essay)
5.0/5
(40)

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

(Short Answer)
4.9/5
(43)
Showing 21 - 40 of 74
close modal

Filters

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