exam questions

Exam 1z0-819 All Questions

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

Exam 1z0-819 topic 1 question 27 discussion

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

Which code fragment represents a valid Comparator implementation?

  • A.
  • B.
  • C.
  • D.
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

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
ASPushkin
3 weeks, 5 days ago
Selected Answer: C
A. wrong public int compare(T o1, T o2) - must be implemeted B. wrong Because it missed generic type parameter should have Object type arguments public int compare (Object obj1, Object obj2) C. correct Anonymous with interface implementation Generic type parameter is String and method compare with String arguments D. wrong wrong return type
upvoted 1 times
...
ASPushkin
4 months, 1 week ago
Selected Answer: A
answer: AC A and C are the same Anonymous with interface as a result there is a valid comparable implementation D failed wrong return type B failed should have raw type arguments public int compare (Object obj1, Object obj2) {
upvoted 1 times
ASPushkin
4 months, 1 week ago
Sorry, A is incorrect should be compare compareTo -> compare
upvoted 1 times
...
...
gnilapon.ebenezaire
6 months ago
Selected Answer: C
Comparator use compare and String implement Comparable who use compareTo so C is correct
upvoted 1 times
...
d7bb0b2
1 year, 1 month ago
c , Comparator has method compare no compareTo, can used in method compare
upvoted 1 times
...
Stavok
1 year, 7 months ago
Selected Answer: C
Correct answer is C . //A is invalid because :The type new Comparator<String>(){} must implement the inherited abstract method Comparator<String>.compare(String, String) //B is invalid because : The type Comps must implement the inherited abstract method Comparator.compare(Object, Object) //D is invalid because : The return type is incompatible with Comparator.compare(Object, Object) and Illegal modifier for the local class Comps; only abstract or final is permitted
upvoted 4 times
...
Mukes877
1 year, 7 months ago
Selected Answer: C
C is correct
upvoted 1 times
...
pikosss
1 year, 10 months ago
Selected Answer: C
Tested
upvoted 2 times
...
TADIEWA
2 years ago
c is correct
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