Consider the following instance variable and method: private List myList; public
ID: 3819631 • Letter: C
Question
Consider the following instance variable and method: private List myList; public boolean testList(String val) {for (String item: nyList) {if (item.coopareTo(val) > 0) return false;} return true;} Which of the following best describes the circumstances under which method teatList returns true? A. When no string in myList comes after val in lexicographic order B. When no string in myList comes before val in lexicographic order C. When no string in my List is the same as val D. When all strings in myList are the same as val When all strings in myList come before val in lexicographic orderExplanation / Answer
A. When no string in myList comes after val in Lexicographic order...
item.compareTo(val) returns greater than 0, when item is lexicographically higher than value.. in order to return true from the method, no item in the list should come after val in lexicographical order.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.