Suppose that we have the following property files and code. Which bundles are used on lines 8 and 9 respectively?
Main.properties /*from w ww .j a v a2 s. c o m*/ name=The Dolphin age=0 Main_en.properties name=Dolly age=4 Main_fr.properties name=Dolly
5: Locale fr = new Locale("fr"); 6: Locale.setDefault(new Locale("en", "US")); 7: ResourceBundle b = ResourceBundle.getBundle("Main", fr); 8: b.getString("name"); 9: b.getString("age");?
D.
Java will use Main_fr.properties as the matching resource bundle on line 7 because it is an exact match on the language of the requested locale.
Line 8 finds a matching key in this file.
Line 9 does not find a match in that file, and therefore it has to look higher up in the hierarchy.
Once a bundle is chosen, only resources in that hierarchy are allowed.