I just took the Self
Test from Chapter 3 of Kathy Sierra & Bert Bates "Sun Certified Programmer & Developer for
Java 2 Exam Study Guide" and I am slightly bewildered by question #2. Here's the question:
Given the following:
1. import java.awt.*;
2. class Ticker extends Component {
3. public static void main (
String [] args) {
4. Ticker t = new Ticker();
5.
6. }
7. }
which two of the following statements, inserted independently, could legally be inserted into line 5 of this code? (Choose two.)
A. boolean test = (Component instanceof t);
B. boolean test = (t instanceof Ticker);
C. boolean test = t.instanceof(Ticker);
D. boolean test = (t instanceof Component);
E. boolean test = t.instanceof(Object);
F. boolean test = (t instanceof String);
I know that A,C, and E are illegal statements (will not compile). But it looks to me like B,D, and F are all legal statements that can bee added to line 5 and not prevent sucessful compilation. But the question states that there are only two correct answers, and the answer key says they are B and E. Is this an inconsistency in the phrasing of the question and the expected answers? Or am I just missing something so obvious that I just can't see it? Any help is appreciated.
David.
[ April 18, 2003: Message edited by: David Willis ]