exam questions

Exam 1z0-809 All Questions

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

Exam 1z0-809 topic 1 question 207 discussion

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

Given the code fragment:
public class Foo {
public static void main (String [ ] args) {
Map<Integer, String> unsortMap = new HashMap< > ( );
unsortMap.put (10, "z");
unsortMap.put (5, "b");
unsortMap.put (1, "d");
unsortMap.put (7, "e");
unsortMap.put (50, "j");
Map<Integer, String> treeMap = new TreeMap <Integer, String> (new
Comparator<Integer> ( ) {
@Override public int compare (Integer o1, Integer o2) {return o1.compareTo
(o2); } } );
treeMap.putAll (unsortMap);
for (Map.Entry<Integer, String> entry : treeMap.entrySet () ) {
System.out.print (entry.getValue () + " ");
}
}
}
What is the result?

  • A. A compilation error occurs.
  • B. d b e z j
  • C. j z e b d
  • D. z b d e j
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

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
jduarte
Highly Voted 3 years, 6 months ago
Answer B. Tested
upvoted 6 times
...
steefaand
Most Recent 5 months, 4 weeks ago
Selected Answer: B
B is correct.
upvoted 1 times
...
duydn
10 months, 2 weeks ago
Selected Answer: B
B is correct
upvoted 1 times
...
WilsonKKerll
2 years, 4 months ago
Answer is B.
upvoted 1 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