Consider the following code. class Apple { // rep-inv: name…

Consider the following code. class Apple { // rep-inv: name != null private String name; public Apple (String name) { if (name == null) throw new NPE(…); this.name = name; } @Override public boolean equals (Object o) { if (!(o instanceof Apple)) { return false; } Apple a = (Apple) o; return name.equals(a.name); } @Override public int hashCode() { … } @Override public String toString() { return name; } } class AppleTracker extends Apple { private static Set inventory = new HashSet (); public AppleTracker (String name) { super(name); inventory.add(name);} public static Set getInventory() { return Collections.unmodifiableSet(inventory);} } // client code Apple a = new Apple(“Winesap”); AppleTracker at1 = new AppleTracker(“Winesap”); AppleTracker at2 = new AppleTracker(“Fuji”); Is the below true or false?at1.equals(a) and a.equals(at2) are both true, but at1.equals(at2) is false. 

Consider the following (incomplete) JUnit theory for compare…

Consider the following (incomplete) JUnit theory for compareTo() (from the Comparable interface) and equals().      @Theory public void compareToConsistentWithEquals( … ) {      assumeTrue (…);   // Assume none of the parameters are null  (i.e. no NPE)      assumeTrue (…);   // Assume parameters are mutually comparable (i.e. no CCE)            assertTrue (…);   //Assume that the assumeTrue(…) statements are correctly implemented.     } How many parameters should this theory have?

Given the JUnit 4 test below:           @Test(expected = Ind…

Given the JUnit 4 test below:           @Test(expected = IndexOutOfBoundsException.class)        public void testIndex() {            List list = new ArrayList();            list.add(“apple”);            list.add(“orange”);            list.get(4);        }   Which of the following is/are true (select all correct answer(s) and no incorrect answer(s) to get credit):