Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
I Danilov
Greenhorn
Posts: 8
3
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
  • 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: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35266
383
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic