Section 11.10 Freestyle Exercise
#
Question
Your Answer
Result / Explanation
11.10.1
Write an expression that tests whether two strings s1 and s2 have the same sequence of characters.
11.10.2
Write an expression that tests whether two lists list1 and list2 have the same contents.
11.10.3
What is the output of the following code?
  public class Test {
    public static void main(String[] args) {
      A a1 = new A();
      A a2 = new A();
      System.out.println(a1.equals(a2));
    }
  }
  class A {
    int x = 1;
  }
11.10.4
What is the output of the following code?
  public class Test {
    public static void main(String[] args) {
      A a1 = new A();
      A a2 = new A();
      System.out.println(a1.equals(a2));
    }
  }
  class A {
    int x = 1;
    public boolean equals(Object o) {
      return this.x == ((A)o).x;
    }
  }