There is one programming question and five other questions.
Instructions for submitting your programming question solution are given in the Programming question section. You may submit as many times as you want; your most recent submission will be the one recorded.
Instructions for submitting your answers to the short answer questions are given in the Short Answer Questions section. You may submit as many times as you want; your most recent submission will be the one recorded.
Implement the Test5C class and provide the Javadoc comments needed to reproduce the API for the two required methods. You may omit the part of the comments that describe the examples (i.e., document the parameters, the return value (if any), and the method description excluding the examples).
Submit your program using the following command in a terminal (make sure you are in the directory containing your file Test5C.java):
submit 2030 test5C Test5C.java
/** * Returns the index within the list t of the last occurrence of the * string s. If s does not occur in the list then -1 is returned. * For example, consider the list t having the elements ["x", "a", "z", "a"]; then * * lastIndexOf("x", t) returns 0 * lastIndexOf("a", t) returns 3 * lastIndexOf("z", t) returns 2 * lastIndexOf("hello", t) returns -1 * * @param s a non-null string * @param t a non-null list * @return the index of the last occurrence of the string s in the * list t */ public static int lastIndexOf(String s, Listt) { if (t.size() == 0) { return -1; } int idx = t.size() - 1; String last = t.get(idx); if (s.equals(last)) { return idx; } return lastIndexOf(s, t.subList(0, idx)); }
Enter your answers into a text file named answers.txt
.
You can use the editor of your choice for this. You can also create a
text file in Eclipse by selecting "New" and then "Untitled Text File" in
the "File" menu. Make sure that you save your file.
Also make sure that you indicate which question you are answering,
e.g. Q1: answer to question 1 Q2: answer to question 2 Q3:...
Submit your answers using the following command in a terminal (make sure you are in the directory containing your file answers.txt):
submit 2030 test5C answers.txt