Win a copy of Getting started with Java on the Raspberry Pi this week in the Raspberry Pi forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

defining interfaces errata item? (Java OCA 8 Programmer I Study Guide)

 
Greenhorn
Posts: 8
3
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's also a mistake (typo?) on p267 rule 4 for defining interfaces:

All top-level interfaces are assumed to have public or default access, and they must include the abstract modifier in their definition.



Should be:

All top-level interfaces are assumed to have public or default access, and they may include the abstract modifier in their definition.



As per Java Language Specification, Java SE 8 Edition, section 9.1.1 Interface Modifiers:

9.1.1.1 abstract Interfaces
Every interface is implicitly abstract.
This modifier is obsolete and should not be used in new programs.


In fact, it has been obsolete even in Java Language Specification, First Edition
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's indeed an errata item. And very easy to confirm: both are valid interface declarations (and don't use the abstract keyword).

Hope it helps!
Kind regards,
Roel
 
I Danilov
Greenhorn
Posts: 8
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In fact, all of the chapter after p267 does not include abstract keyword in interface declarations; p268 contains explanation that abstract keyword is implicit.

Though it may be noted that using abstract modifier for interfaces is not only unnecessary, but discouraged.
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I Danilov wrote:Though it may be noted that using abstract modifier for interfaces is not only unnecessary, but discouraged.


True! But don't forget you are preparing for a certification exam, not for an assignment to win the cleanest code award. Meaning: although the use of the abstract keyword is discouraged in an interface definition, you still need to know this code is valid and will compile without any error.
 
author & internet detective
Posts: 41763
885
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, it took me a while to get to this. When I read this, my first reaction was that there was no way the book said that. Of course "abstract" is unnecessary and discouraged. But there it is.

Congratulations on being the second person to report an errata that actually affects meaning (vs an annoying typo.) I've given you a cow here and credited you with this finding in the errata.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic