exam questions

Exam 1z0-829 All Questions

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

Exam 1z0-829 topic 1 question 24 discussion

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

Given the code fragment:

What is the result?

  • A. 1
    2
    -4
  • B. 2
    -2
  • C. 1
    1
    1
  • D. 2
    2
    0
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
SrinivasJasti
2 weeks, 2 days ago
Selected Answer: A
for binarysearch the list has be sorted ascending, for x1 binarysearch has assumed it sorted and got 1 where as for x3 the after reverse the list is still not sorted should give negative value
upvoted 1 times
...
xplorerpj
6 months, 3 weeks ago
A is correct answer
upvoted 1 times
...
james2033
10 months, 4 weeks ago
Selected Answer: A
package q24; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class Q24 { public static void main(String[] args) { List lst = new ArrayList(); lst.add("e1"); lst.add("e3"); lst.add("e2"); int x1 = Collections.binarySearch(lst, "e3"); System.out.println(x1); Collections.sort(lst); int x2 = Collections.binarySearch(lst, "e3"); System.out.println(x2); Collections.reverse(lst); int x3 = Collections.binarySearch(lst, "e3"); System.out.println(x3); } } // Result: // 1 // 2 // -4
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