GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

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

Consider the following code snippet which is supposed to sho…

Consider the following code snippet which is supposed to show the total order amount when the button is clicked: public static void main(String[] args) { final Order myOrder = new Order(); JButton button = new JButton(“Calculate”); final JLabel label = new JLabel(“Total amount due”); . . . class MyListener implements ActionListener { public void actionPerformed(ActionEvent event) { label.setText(“Total amount due ” + myOrder.getAmountDue()); } } ActionListener listener = new MyListener(); } What is wrong with this code?

Read Details

Which data structure would best be used for keeping track of…

Which data structure would best be used for keeping track of groceries to be purchased at the food market?

Read Details

Consider the following code snippet: public class Coin { pr…

Consider the following code snippet: public class Coin { private String name; . . . public boolean equals(Object otherCoin) { return name.equals(otherCoin.name); } . . . } What is wrong with this code?

Read Details

Assume inputFile is a Scanner object used to read data from…

Assume inputFile is a Scanner object used to read data from a text file that contains a series of double values. Select an expression to complete the following code segment, which reads the values and prints them in standard output, one per line, in a field 15 characters wide, with two digits after the decimal point. while (inputFile.hasNextDouble()) { double value = inputFile.nextDouble(); ___________________________________ // statement to display double value }

Read Details

What reserved word in a method definition ensures that subcl…

What reserved word in a method definition ensures that subclasses cannot override the method?

Read Details

Posts pagination

Newer posts 1 … 76,285 76,286 76,287 76,288 76,289 … 81,562 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top