A ____ is a data structure used for collecting a sequence of objects that allows efficient addition and removal of already-located elements in the middle of the sequence.
Blog
When reading words with a Scanner object, a word is defined…
When reading words with a Scanner object, a word is defined as ____.
Consider the following code snippet: Scanner in = new Scanne…
Consider the following code snippet: Scanner in = new Scanner(. . .); while (in.hasNextLine()) { String input = in.nextLine(); System.out.println(input); } Which of the following statements about this code is correct?
You wish to use the Scanner class’s nextInt() method to read…
You wish to use the Scanner class’s nextInt() method to read in whole numbers. To avoid exceptions that would occur if the input is not a whole number, you should use the ____ method before calling nextInt().
Which statement is true about backtracking?
Which statement is true about backtracking?
Which of the following classes implement the Comparable inte…
Which of the following classes implement the Comparable interface? I Date II Collections III String
A palindrome is a word or phrase that reads the same forward…
A palindrome is a word or phrase that reads the same forward or backward. Consider the methods palindrome and isPal shown below: public boolean palindrome(String string) { return isPal(string, 0, string.length() – 1); } private boolean isPal(String string, int left, int right) { if (left >= right) { return true; } else if (string.charAt(left) == string.charAt(right)) { return isPal(string, left + 1, right – 1); } else { return false; } } The method isPal as shown here would be considered to be a ____ method.
The merge sort algorithm presented in section 14.4, which so…
The merge sort algorithm presented in section 14.4, which sorts an array of integers in ascending order, uses the merge method which is partially shown below. Select the condition that would be needed to complete the method so that the elements are sorted in descending order. private static void merge(int[] first, int[] second, int[] a) { int iFirst = 0; int iSecond = 0; int j = 0; while (iFirst < first.length && iSecond < second.length) { if (_____________________________) { a[j] = first[iFirst]; iFirst++; } else { a[j] = second[iSecond]; iSecond++; } j++; } // rest of the method follows here }
Consider the following code snippet. public interface Measu…
Consider the following code snippet. public interface Measurable { double getMeasure(); } public class Coin implements Measurable { public Coin(double aValue, String aName) { … } public double getMeasure() { return value; } … } public class BankAccount implements Measurable { public BankAccount(double initBalance) { … } public void getMeasure() { return balance; } … } Which of the following statements is correct?
The code below will not compile successfully unless the argu…
The code below will not compile successfully unless the argument to the makeMenuItem method is final. Why not? public JMenuItem makeMenuItem(final String menuLabel) { JMenuItem mi = new JMenuItem(menuLabel); class MyMenuListener implements ActionListener { public void actionPerformed(ActionEvent e) { doSomethingElse(); System.out.println(menuLabel); } } mi.addActionListener(new MyMenuListener()); return mi; }