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