Question: QUESTION 1 Why does the following recursive method fail? if (n public long factorial(short n) { long result = n * factorial(n-1); 1) { return


QUESTION 1 Why does the following recursive method fail? if (n public long factorial(short n) { long result = n * factorial(n-1); 1) { return 1:3 return result; } factorial(10); QUESTION 2 Why does the following codes fail? public static int xMethod2(int n) { if (n == 1) return 1; else return n + xMethod2(n + 1); } int result = xMethod2(2); QUESTION 3 Which of the following statements about interface are correct? A. An interface may contain constructors. B. An interface can be instantiated C. All the methods in an interface are abstract D. A class can only implement one interface. E. If a class implements an interface, it should implement all the abstract methods in the interface. QUESTION 4 What is the recursive relation for binary search? [A] QUESTION 5 Given the following array: 710 3 065 1146 What will the array look like after the first partition? [A] Suppose we choose the last element 6 as our pivot
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
