• 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

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: 72407
315
  • 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.
 
Ranch Foreman
Posts: 325
8
  • 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.
Staff note (Paul Clapham) :

Thanks. I moved it to the OCPJP forum.

 
Sheriff
Posts: 22116
114
Eclipse IDE Spring VI Editor Chrome Java Windows
  • 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?
 
Alas, poor Yorick, he knew this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic