exam questions

Exam 1z0-809 All Questions

View all questions & answers for the 1z0-809 exam

Exam 1z0-809 topic 1 question 75 discussion

Actual exam question from Oracle's 1z0-809
Question #: 75
Topic #: 1
[All 1z0-809 Questions]

Given:
class CheckClass {
public static int checkValue (String s1, String s2) {
return s1 length() "" s2.length();
}
}
and the code fragment:
String[] strArray = new String [] {"Tiger", "Rat", "Cat", "Lion"};
//line n1
for (String s : strArray) {
System.out.print (s + " ");
}
Which code fragment should be inserted at line n1 to enable the code to print Rat Cat Lion Tiger?

  • A. Arrays.sort(strArray, CheckClass : : checkValue);
  • B. Arrays.sort(strArray, (CheckClass : : new) : : checkValue);
  • C. Arrays.sort(strArray, (CheckClass : : new).checkValue);
  • D. Arrays.sort(strArray, CheckClass : : new : : checkValue);
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
pul26
Highly Voted 3 years, 7 months ago
seem checkValue method is wrong. class CheckClass { public static int checkValue (String s1, String s2) { return Integer.compare(s1.length(), s2.length()); } } Answer is A
upvoted 6 times
...
asdfjhfgjuaDCV
Most Recent 4 months, 3 weeks ago
A is the correct answer
upvoted 1 times
...
steefaand
5 months, 3 weeks ago
Selected Answer: A
Answer A, just replace "" in checkValue with - sign.
upvoted 1 times
...
Svetleto13
3 years, 2 months ago
A,tested
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago