Question: Provide: A failure - inducing input for the buggy program, as a JUnit test and any associated code ( write it as a code block
Provide:
A failureinducing input for the buggy program, as a JUnit test and any associated code write it as a code block in Markdown
An input that doesn't induce a failure, as a JUnit test and any associated code write it as a code block in Markdown
The symptom, as the output of running the tests provide it as a screenshot of running JUnit with at least the two inputs above
The bug, as the beforeandafter code change required to fix it as two code blocks in Markdown
Briefly describe why the fix addresses the issue.
Buggy Program:
import java.util.ArrayList;
import java.util.List;
interface StringChecker boolean checkStringString s;
class ListExamples
Returns a new list that has all the elements of the input list for which
the StringChecker returns true, and not the elements that return false, in
the same order they appeared in the input list;
static List filterList list, StringChecker sc
List result new ArrayList;
forString s: list
ifsccheckStrings
result.add s;
return result;
Takes two sorted list of strings so a appears before b and so on
and return a new list that has all the strings in both list in sorted order.
static List mergeList list List list
List result new ArrayList;
int index index;
whileindex listsize && index listsize
iflistgetindexcompareTolistgetindex
result.addlistgetindex;
index;
else
result.addlistgetindex;
index;
whileindex listsize
result.addlistgetindex;
index;
whileindex listsize
result.addlistgetindex;
index;
return result;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
