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

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: 41967
911
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.
 
Barry's not gonna like this. Barry's not gonna like this one bit. What is Barry's deal with tiny ads?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic