Section 21.2.2 Check Point Questions3 questions 

21.2.2.1
Show the output of the following code:
import java.util.*;

public class Test {
  public static void main(String[] args) {
    LinkedHashSet<String> set1 = new LinkedHashSet<>();
    set1.add("New York");
    LinkedHashSet<String> set2 = set1;
    LinkedHashSet<String> set3 = 
      (LinkedHashSet<String>)(set1.clone());
    set1.add("Atlanta");
    System.out.println("set1 is " + set1);
    System.out.println("set2 is " + set2);
    System.out.println("set3 is " + set3);
    set1.forEach(e -> System.out.print(e + " "));
  }
}
21.2.2.2
Show the output of the following code:
Set<String> set = new LinkedHashSet<>();
set.add("ABC");
set.add("ABD");
System.out.println(set);
21.2.2.3
Show the output of the following code:
import java.util.*;
import java.io.*;

public class Test {
  public static void main(String[] args) throws Exception {
    ObjectOutputStream output = new ObjectOutputStream(
      new FileOutputStream("c:\\test.dat"));
    LinkedHashSet<String> set1 = new LinkedHashSet<>();
    set1.add("New York");
    LinkedHashSet<String> set2 = 
      (LinkedHashSet<String>)set1.clone();
    set1.add("Atlanta");
    output.writeObject(set1);
    output.writeObject(set2);
    output.close();

    ObjectInputStream input = new ObjectInputStream(
      new FileInputStream("c:\\test.dat"));
    set1 = (LinkedHashSet<String>)input.readObject();  
    set2 = (LinkedHashSet<String>)input.readObject();  
    System.out.println(set1);        
    System.out.println(set2);        
    input.close();
  }
}