Consider the following method. public static String abMetho…

Consider the following method. public static String abMethod(String a, String b) { int x = a.indexOf(b);   while (x >= 0) { a = a.substring(0, x) + a.substring(x + b.length()); x = a.indexOf(b); }   return a; } What, if anything, is returned by the method call abMethod(“sing the song”, “ng”) ?

Consider the following method. /** Precondition: Strings on…

Consider the following method. /** Precondition: Strings one and two have the same length. */ public static String combine(String one, String two) { String res = “”; for (int k = 0; k < one.length(); k++) { if (one.substring(k, k + 1).equals(two.substring(k, k + 1))) { res += one.substring(k, k + 1); } else { res += "0"; } } return res; } What is returned as a result of the call combine("10110", "01100") ?

Consider the following methods, which appear in the same cla…

Consider the following methods, which appear in the same class. public int function1(int i, int j) { return i + j; }   public int function2(int i, int j) { return j – i; } Which of the following statements, if located in a method in the same class, will initialize the variable x to 11?

Consider the following code segment. /* missing loop header…

Consider the following code segment. /* missing loop header */ { for (int k = 0; k < 4; k++) { System.out.print(k); } System.out.println(); } The code segment is intended to produce the following output. 0123 0123 0123 Which of the following can be used to replace /* missing loop header */ so that the code segment works as intended? for (int j = 0; j < 3; j++) for (int j = 1; j < 3; j++) for (int j = 1; j