Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

enum on OCA exam objectives

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm wondering as whether enum is still on the objective topic of the OCA since I don't see Sybex mention this.
 
Bartender
Posts: 1868
81
Android IntelliJ IDE MySQL Database Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most likely questions regarding enum will not be on the Java 808 OCA exam.
That said, for the OCA level of questions, enums can be thought of as final classes.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Pete Letkeman, Sorry for my greenhorn arrogance but are you sure that an enum class can be final?  (of course enums themselves are always final)

https://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.9
"It is a compile-time error if an enum declaration has the modifier abstract or final."
 
Marshal
Posts: 69373
276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch
What is the difference between an “enum class” and an enum? Pete said that enums are final classes, which matches what the Java® Language Specification says.
 
Marshal
Posts: 25594
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
https://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.9

"It is a compile-time error if an enum declaration has the modifier abstract or final.
An enum declaration is implicitly final unless it contains at least one enum constant that has a class body (§8.9.1)."
 
author & internet detective
Posts: 39986
806
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Enums are on page 72 of the Sybex 1Z0-808 book.
 
Teodor Ian
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much, now I understand.
The misunderstanding was that English is not my mother tongue and I translated in my head: "enum can be thought of as a final class".
 
Campbell Ritchie
Marshal
Posts: 69373
276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quoting from the JLS link given earlier.

Paul Clapham wrote:. . . An enum declaration is implicitly final unless it contains at least one enum constant that has a class body (§8.9.1)."


I think I misunderstood that bit about implicitly final at first. I thought that meant that an enum with class bodies can be extended by a different XXX.java file or compilation unit. I think it actually means that enums with class bodies extend themselves. They cannot be extended elsewhere. The constants with class bodies look like instances of anonymous classes. I don't know whether they really are anonymous classes.
If you write a compilation unit extending an enum with class bodies for every constant, e.g. the Operation enum from the Java™ Language Specification (=JLS), you will see you get a compiler error.
If you go through the first JLS link I gave you, you will find out why you can't write enum XYZ extends...
 
CAUTION! Do not touch the blades on your neck propeller while they are active. Tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic