What is the result of the following?.
Map<String, String> map = new TreeMap<>(); map.put("tool", "HTML"); map.put("problem", "Markup"); Properties props = new Properties(); // p1 map.forEach((k,v) -> props.put(k, v)); // p2 String t = props.get("tool"); // p3 String n = props.get("Markup"); System.out.println(t + " " + n);
D.
The Properties class implements Map.
While the get()
method, inherited from the superclass, is available, it returns an Object.
Since Object cannot be cast to String, it does not compile, and Option D is the answer.