Oracle
1Z0-819 · Question #153
1Z0-819 Question #153: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-819 to reveal the answer and full explanation for question #153. The question stem and answer options stay visible for context.
Question
Given:
import java.util.*;
public class Main {
static Map<String, String> map = new HashMap<>();
static List<String> keys =
new ArrayList<>(List.of("A", "B", "C", "D"));
static String[] values =
{"one", "two", "three", "four"};
{
for (var i = 0; i < keys.size(); i++) {
map.put(keys.get(i), values[i]);
}
}
public static void main(String[] args) {
keys.clear();
values = new String[0];
System.out.println("Map: " + map.size() +
" Keys: " + keys.size() +
" Values: " + values.length);
}
}
What is the result?
Options
- AMap: 0 Keys: 0 Values: 0
- BThe compilation fails.
- CMap: 4 Keys: 4 Values: 4
- DMap: 4 Keys: 0 Values: 0
- EMap: 4 Keys: 0 Values: 4
Unlock 1Z0-819 to see the answer
You've previewed enough free 1Z0-819 questions. Unlock 1Z0-819 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.