Question in the book: Which statements about the following Twins class are true? (Choose three.)
A. The class fails to compile because of the write() method.
B. The class fails to compile because of the publish() method.
C. The class fails to compile because of the think() method.
D. All of the methods defined in the Alex interface are accessible in the Twins class.
E. All of the methods defined in the Michael interface are accessible in the Twins class.
F. The Twins class cannot be marked abstract.
Answer in the book: A, C, E
All of the interface methods without a private modifier are implicitly public. In a class, though, a method without a modifier is package-private by default. For this reason, the write() and think() methods do not compile because they are missing the public modifier, making options A and C correct. These are the only compiler errors, making option B incorrect. Option D is incorrect because the process() method is not accessible with Twins because it is private. Option E is correct, as all methods are accessible. Even the overridden default method can be accessed in the Twins class by calling Michael.super.write(). Finally, option F is incorrect as the class still compiles if it is marked abstract.
I think option E is incorrect. Method study() in Michael interface is private. It's not accessible from Twins class.
Yup, yup, yup. Tiny ad:
SKIP - a book about connecting industrious people with elderly land owners