What is the output of the following Java program?
import java.util.*;
public class Main {
static class P {
int x;
P(int x) { this.x = x; }
public boolean equals(Object o) { return o instanceof P && ((P) o).x == x; }
}
public static void main(String[] args) {
Set<P> s = new HashSet<>();
s.add(new P(1));
s.add(new P(1));
System.out.println(s.size() + " " + new P(1).equals(new P(1)));
}
}- A1 true
- B2 true
- C2 false
- D1 false
Correct answer: B