Java OCA OCP Practice Question 2516

Question

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"); 
  • A. Dolphins.properties and Dolphins.properties
  • B. Dolphins.properties and Dolphins_fr.properties
  • C. Dolphins_fr.properties and Dolphins_fr.properties
  • D. Dolphins_fr.properties and Dolphins.properties
  • E. Dolphins_fr.properties and Dolphins_fr_CA.properties
  • F. Dolphins_fr_CA.properties and Dolphins_fr.properties


D.

Note

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.




PreviousNext

Related