• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Sybex 829 errata? what is "the enum name is missing before the enum value green"?

 
Ranch Hand
Posts: 662
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Line 20 does not compile because the enum name is missing before the enum value green.


I am trying to understand what this line is talking about. I only see the error of the semicolon when I compile and run it, so my answer is B.

tb864615.OCPJAVASE17PT.c14.015
Lesson Reference: Chapter 14: Practice Test 3
Difficulty: hard
What is the output of the following application?



A. Painting: 00FF00
B. Exactly one line of code does not compile.
C. Exactly two lines of code do not compile.
D. Three or more lines of code do not compile.
E. The code compiles but prints an exception at runtime.
F. None of the above.

Rationale
Line 10 does not compile because line 9 is missing a semicolon (;) at the end of it.
A semicolon is required after a list of enum values if the enum containsanything besides the list of values.
Line 20 does not compile because the enum name is missing before the enum value green.
For these two reasons,option C is correct.

 
Anil Philip
Ranch Hand
Posts: 662
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it now. It should be COLORS.green

My IDE had done an import:


But I have an issue with this. The Boyarsky-Selikoff PT book says that one should assume all imports are correct.
So if I assumed the static import was in place, then it would have worked correctly - with the only error being the missing semi-colon.
 
Beware the other head of science - it bites! Nibble on this message:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic