Question: 6. Consider the following Java method. /** (Total: 77 = 14 marks) * Returns a palindrome version of a String where the * original

6. Consider the following Java method. /** (Total: 77 = 14 marks) 

6. Consider the following Java method. /** (Total: 77 = 14 marks) * Returns a palindrome version of a String where the * original String is followed by its reverse. * * @param s a String that we want to make into a palindrome * @returns followed by the reverse of s * @throws IllegalArgumentException if s is null */ public static String toPalindrome (String s) { if (s == null) throw new IllegalArgumentException(); String result = ""; for (int i = 1; i >= 0; i--) { results.charAt(i) + result%;B s.length() result results.charAt(i); } return result; } (a) Write test cases for JUnit 4 that together achieve test coverage for this method (i.e., for each statement in the method to Palindrome there should be at least one test case that uses the statement). Ensure that a test fails if running the test takes more than 3000 milliseconds. Hint: Remember to use suitable Java annotations to label methods as JUnit test cases. 7 mark (b) Write a recursive method 7 mark public static String toPalindrome Recursive(String s) that has the same functionality as the method to Palindrome. You are not allowed to use loops for this method.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a Here are some test cases for JUnit 4 that achieve test coverage for the toPalindrome method import ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!