• 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:

OCPJP Study Guide: Chapter 5 - Possible errata on Question #5

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


Suppose that we have the following property files and code. Which bundles are used on lines 8 and 9 respectively?

Dolphins.properties
name=The Dolphin
age=0

Dolphins_en.properties
name=Dolly
age=4

Dolphins_fr.properties
name=Dolly



...



The correct answer according to page 558 is:
D. Dolphins_fr.properties and Dolphins.properties

It should have been:
D. Dolphins_fr.properties and Dolphins_en.properties

Line 9 should find a match in the English resource file for "age" as it is the default locale (BTW en-US happens to be the default locale on my computer even though I'm in Europe, even without setting it explicitly).
This goes in accordance with table 5.7 in p.264: first we look for the requested locale, as it is not defined there we go to the default locale, and then we would hit the default file but in this case it doesn't need to.

Am I missing something here?
 
author & internet detective
Posts: 42173
937
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
John,
It's right in the book. Really; give it a shot. The rules you quoted are for finding a resource bundle. Once Java finds one, it can only use the hierarchy. In other words, once it finds the French one, it is too late to switch to the default locale.

Table 5.7 is only used for finding the initial bundle. Once a bundle is found, table 5.8 comes into play. Which is what this question is testing you on.
 
Did you just should on me? You should read 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