Collections and Generics

© examsiri.com
Question : 49 of 53
 
Marks: +1, -0
Given:
import java.util.*;
public class Group extends HashSet < Person > {
  public static void main(String[] args) {
   Group g = new Group();
   g.add(new Person("Hans"));
   g.add(new Person("Lotte"));
   g.add(new Person("Jane"));
   g.add(new Person("Hans"));
   g.add(new Person("Jane"));
   System.out.println("Total: " + g.size());
  }
  public boolean add(Object o) {
   System.out.println("Adding: " + o);
   return super.add(o);
  }
}
class Person {
  private final String name;
  public Person(String name) { this.name = name; }
  public String toString() { return name; }
}

Which of the following occur at least once when the code is compiled and run?(Choose all that apply.)
Go to Question: