Suppose that we have the following property files and code. Which bundle is used on lines 7 and 8, respectively?
Dolphins.properties //from ww w . j ava2 s .c o m name=The Dolphin age=0 ? Dolphins_fr.properties name=Dolly ? Dolphins_fr_CA.properties name=Dolly age=4
5: Locale fr = new Locale("fr"); 6: ResourceBundle b = ResourceBundle.getBundle("Dolphins", fr); 7: b.getString("name"); 8: b.getString("age");
D.
Java will use Dolphins_fr.properties as the matching resource bundle on line 6 because it is an exact match on the language.
Line 7 finds a matching key in this file.
Line 8 does not find a match in that file, and therefore it has to look higher up in the hierarchy.