What is the result of the following?.
Map<Object, Object> 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.getProperty("tool"); // p3 String n = props.getProperty("problem"); System.out.println(t + " " + n);
A.
This code creates a Map with two elements.
Then it copies both key/value pairs to a Properties object.
This works because a Properties object is also a Map and therefore has a put()
method that takes Object parameters.
The code gets the String property values of both keys and prints HTML Markup.
Therefore, Option A is correct.