Question: 7 Which of the code segments below will correctly print the names of the Person objects in people? Why? I. for (Iterator it = people

7  7 Which of the code segments below will correctly print the

Which of the code segments below will correctly print the names of the Person objects in people? Why? I. for (Iterator it = people Iterator (; it Next():] {Person temp = it.next[]; System out.println (temp.getName()];) II. for (Iterator it = people get[0]; hasNext[];) {Person temp=it.next []; System.out.println (temp.getName()]; III. Iterator it = people iterator(); While (it.hasNext()}{Person temp = it.next(); System.out println (temp.getName();} a. I only b. II only c. III only d. I and III only e. I, II, and III The following segment of code is executed. people add (new Person ("Anna", 23)); people.add (new Person ("Thomas', 17)); people.add(new Person ("Lara", 19)); people.add (new.Person ("David", 34)); people.add (new Person ("Karen", 22)); Iterator it=people.iterator (); it.next(); it.next(); Person temp= it.next(); it.remove (); temp = it.next(); System.out.println (temp.getName()]; What will be printed to the screen? Why? a. Anna b. Thomas c. Lara d. David e. Karen

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!