Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 4 (1 point) What prints? ArrayList list = new ArrayList 0; list.add(2); list.add(3); list.add(5); list.add(5); list.add(3); list.add(6); HashMap map = new HashMap (); for
Question 4 (1 point) What prints? ArrayList list = new ArrayList 0; list.add(2); list.add(3); list.add(5); list.add(5); list.add(3); list.add(6); HashMap map = new HashMap (); for (Integer i: list) \{ if (!map.containsKey(i)) \{ map.put(i, 1); \} else \{ map.put(i, map.get(i) * 2); \} \} System.out.print(map.get(5)); Question 5 (1 point) What prints? Collection list = new ArrayList ) ; list.add(2); list.add(3); list.add(5); list.add(5); list.add(3); list.add(6); Collection set = new HashSet 0; ArrayList collections = new ArrayList 0 ); collections.add(list); collections.add(set); Iterator> iter = collections.get(0). iterator(); while (iter.hasNext()) \{ collections.get(1).add(iter.next()); \} System.out.print(collections.get(1).size())
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started