GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

The Comparable interface consists of a single method called…

The Comparable interface consists of a single method called ____.

Read Details

A binary search is generally ____ a linear search.

A binary search is generally ____ a linear search.

Read Details

Which of the following arrays can be used in a call to the A…

Which of the following arrays can be used in a call to the Arrays.sort method? I     Any array with primitive numeric data, such as int, double, … II    Arrays of String or numeric wrapper classes like, Integer, Double, … III   Any class that implements the Comparable interface

Read Details

Consider the permutations method from the textbook, which is…

Consider the permutations method from the textbook, which is intended to return all permutations of the word passed in as a parameter. What special cases for the simplest values are used by the permutations method to terminate the recursion? public static ArrayList permutations(String word) { ArrayList result = new ArrayList(); if (word.length() == 0) // line #1 { result.add(word); // line #2 return result; // line #3 } else { for (int i = 0; i < word.length(); i++) // line #4 { String shorter = word.substring(0, i) + word(substring(i + 1); // line #5 ArrayList shorterPermutations = permutations(shorter); // line #6 for (String s : shorterPermutations) // line #7 { result.add(word.charAt(i) + s); // line #8 } } return result; // line #9 } }

Read Details

When writing a method, which of the following statements abo…

When writing a method, which of the following statements about exception handling is true?

Read Details

Suppose objects a and b are from a user-defined class that i…

Suppose objects a and b are from a user-defined class that implements the Comparable interface.  What must be true about the return value of a.compareTo(b) for the compareTo method that this class implements?

Read Details

Which sort algorithm starts by partitioning the array and se…

Which sort algorithm starts by partitioning the array and selecting a pivot element?

Read Details

The partial linear search method below is designed to search…

The partial linear search method below is designed to search an array of String objects.  Select the expression that would be needed to complete the method. public static int search(String[] a, String item) { for(int i = 0; i < a.length; i++) { if ( ____________________________ ) { return i; } return -1; } }

Read Details

Assuming that names is a Queue of String objects, select a s…

Assuming that names is a Queue of String objects, select a statement to complete the code segment below.  The code is designed to remove the last element from the queue, which is guaranteed to have at least one element. Queue aQueue = new LinkedList(); while (names.size() > 1) { aQueue.add(names.remove()); } names.remove(); while (aQueue.size() > 0) { ____________________________ }

Read Details

Assuming that names is a Queue of String objects, select a s…

Assuming that names is a Queue of String objects, select a statement to complete the code segment below.  The code is designed to remove the last element from the queue, which is guaranteed to have at least one element. Queue aQueue = new LinkedList(); while (names.size() > 1) { aQueue.add(names.remove()); } names.remove(); while (aQueue.size() > 0) { ____________________________ }

Read Details

Posts pagination

Newer posts 1 … 76,275 76,276 76,277 76,278 76,279 … 81,552 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top