boolean b = (obj instanceof A) && ! (obj instanceof C) && ! (obj instanceof D); System.out.print(b); } } </CODE> Question: Given the following class definitions, the expression obj instanceof A) && ! (obj instanceof C) && ! (obj instanceof D) correctly identifies whether the object referred to by obj was created by instantiating class B rather than classes A, C and D? Ans: False Explanation: Correct answer would be(obj instanceof B) && ! (obj instanceof C) In fact the last part !(obj instanceof D) of the given answer is redundant because anything which is not instance of C cannot be an instanceof D either ! My thought: Eventhough !(obj instanceof C) is redundant, still the above expression correctly identifies obj to be true if it is a class of B..? So the answer should be True? even though this expression may not be shortest form of evaluation?...

Ragu [This message has been edited by Ragu Sivaraman (edited December 02, 2001).]