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

OCP 816 Sybex - Chapter 2, Q2 page94 .

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the annotation

I dont think that this line with 'Color' compiles and so "line 6 " ie option  E should be one of the incorrect options   given  on the answer page 662
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Thank you for using the code button but you didn't quite get it right. Please see this link about it. The two halves of the tags go around the code, but don't worry. I corrected it for you. Doesn't it look better (). Please don't double‑space code.
Have you tried compiling that annotation? What happened? Please supply more details for those of us who don't have the book.
 
Bartender
Posts: 1737
63
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It should probably be in the OCJP Forum, rather than Java in General, since the OP was alleging an incorrect answer in cert exam prep materials provided by authors who frequent the Ranch.

The full code of the example is:


The answer choices are:
A. Line 2
B. Line 3
C. Line 4
D. Line 5
E. Line 6
F. Line 7
G. All of the lines compile.

I agree with the printed book's explanation that only D and F represent lines that would not compile.
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If Color is an enum, there is no reason that line won't compile. If Color is a normal class then you'll indeed get a compiler error. If you're trying this out in an IDE and get an error on this line, are you perhaps using java.awt.Color unintentionally?
 
reply
    Bookmark Topic Watch Topic
  • New Topic