• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Sybex Practice Tests 11 - Chapter 3 - Q #213

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question in the book: Which statements about the following Twins class are true? (Choose three.)


Variants:
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.
 
Roses are red, violets are blue. Some poems rhyme and some don't. And some poems are a tiny ad.
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic