Question: Which one is a fault in the following program? public int findLast (int]x, inty) WEffects: Ifx--null throw NullPointerException l else retun the index of the

Which one is a fault in the following program? public int findLast (int]x, inty) WEffects: Ifx--null throw NullPointerException l else retun the index of the last element in x that equals y /l If no such element exists, return-1 for (int i-x length-1; i> 0; i--) if (y) return1 return -1; // test: x=[2. 3. 5]; y /l Expected-0 2 for (int i=x-length-1: i > 0 (fault); i-) for (int i-x-length-1(fault); i > 0; i-) if ly) fault return i (fault)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
