• 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

A possible typo in the code example of question 18 in chapter 10 (OCP 17 - Practice Tests)

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

With reference to the code example of question 18 in chapter 10 of the OCP Oracle Certified Professional Java SE 17 Developer Practice Tests: Exam 1Z0-829 (English Edition) book (Kindle edition), shown below.

I believe the example is missing an opening curly bracket or has an extra closing curly bracket.
Question.png
[Thumbnail for Question.png]
 
Saloon Keeper
Posts: 15655
367
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not necessarily. The code is formatted very poorly, obscuring the fact that the final curly brace might belong to an opening brace that precedes the code snippet shown. Here's what the code looks like when formatted more clearly:

I agree that it's sloppy though, and it should probably be fixed.
 
author & internet detective
Posts: 41936
910
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While I like the mystery code explanation, the second to last } shouldn't be there. I put in the errata.

While it is reasonable for the reader to assume imports and wrapping methods/classes, they should be both halves. We don't get to include the closing } from a method and not the opening one.
reply
    Bookmark Topic Watch Topic
  • New Topic