• 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
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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

 
Ranch Hand
Posts: 684
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: 684
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.
 
It sure was nice of your sister to lend us her car. Let's show our appreciation by sharing this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic