Consider the method below, which displays the characters from a String in reverse order. Each character appears on a separate line. Select the statement that should be used to complete the method so that it performs a recursive method call correctly. public static void printReverse(String word) { if (word.length() > 0) { ___________________________ System.out.println(word.charAt(0)); } }
Which of the following objects should be used for reading fr…
Which of the following objects should be used for reading from a text file?
Which of the following classes have a user-editable area?
Which of the following classes have a user-editable area?
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 following code snippet: 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; } } What is the purpose of the palindrome method?
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 following code snippet: 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; } } What is the purpose of the palindrome method?
If the user wants to process keystrokes, which methods of th…
If the user wants to process keystrokes, which methods of the KeyListener interface must be implemented?
If you have multiple classes in your program that have imple…
If you have multiple classes in your program that have implemented the same interface in different ways, how is the correct method executed?
Suppose you wish to implement the Comparable interface to al…
Suppose you wish to implement the Comparable interface to allow your Vehicle class to compare Auto objects only. Which of the following is the correct way to do this?
A portion of your program includes the loops shown in the co…
A portion of your program includes the loops shown in the code snippet below to examine the elements of two arrays, arr1 and arr2, both of length n: int matches = 0; for (int i = 0; i < arr1.length; i++) { for (int j = 0; j < arr2.length; j++) { if (arr1.equals(arr2)) { matches++; } } } What can you conclude about the running time of this section of code?
Suppose a developer gets class XYZ files and documentation f…
Suppose a developer gets class XYZ files and documentation from a subcontractor. This class does not implement the Comparable interface. What must be true in order for the developer to sort an array of XYZ objects without modifying the XYZ class?