Exam 9: Advanced Array Concepts

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

Swapping two values can be accomplished with two statements.

(True/False)
4.8/5
(39)
Match each term with the correct statement below.
Premises:
The size can change during program execution
Responses:
java.util
multidimensional array
static methods
Correct Answer:
Verified
Premises:
Responses:
The size can change during program execution
java.util
(Matching)
4.9/5
(27)

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.

(Essay)
4.9/5
(34)

Write the code for bubble sorting a someNums array of integers.

(Essay)
4.9/5
(40)

When mathematicians use a two-dimensional array, they often call it a ____.

(Multiple Choice)
4.9/5
(39)

Declare an ArrayList that declares a list of strings with a capacity of 20.

(Essay)
4.9/5
(39)
Match each term with the correct statement below.
Premises:
A data type for which only appropriate behaviors are allowed.
Responses:
two-dimensional array
add() method
Enumerated data type
Correct Answer:
Verified
Premises:
Responses:
A data type for which only appropriate behaviors are allowed.
two-dimensional array
(Matching)
4.8/5
(41)

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

(Multiple Choice)
4.8/5
(43)

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 .

(Essay)
4.8/5
(36)
Match each term with the correct statement below.
Premises:
Arrays with more than one dimension
Responses:
type-safe
jagged array
dynamically resizable
Correct Answer:
Verified
Premises:
Responses:
Arrays with more than one dimension
type-safe
(Matching)
4.8/5
(38)

You can think of the single dimension of a single dimensional array as the height of the array.

(True/False)
4.8/5
(40)

The simplest possible sort involves two values that are out of order.

(True/False)
4.9/5
(35)

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?

(Essay)
4.9/5
(36)

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

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.

(Multiple Choice)
4.9/5
(39)
Match each term with the correct statement below.
Premises:
A package containing the Arrays class
Responses:
one-dimensional array
java.util
two-dimensional array
Correct Answer:
Verified
Premises:
Responses:
A package containing the Arrays class
one-dimensional array
(Matching)
4.8/5
(43)

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

(Multiple Choice)
4.9/5
(36)

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)
4.8/5
(35)
Match each term with the correct statement below.
Premises:
A two-dimensional array that has rows of different lengths
Responses:
jagged array
two-dimensional array
ascending order
Correct Answer:
Verified
Premises:
Responses:
A two-dimensional array that has rows of different lengths
jagged array
(Matching)
4.8/5
(41)

What is sorting and how are objects organized as a result of being sorted?

(Essay)
4.8/5
(34)
Showing 41 - 60 of 80
close modal

Filters

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