Exam 1z0-829 All QuestionsBrowse all questions from this exam
Question 44

Given:

Captions.properties file:

user = UserName

Captions_en.properties file:

user = User name (EN)

Captions_US.properties file:

message = User name (US)

Captions_en_US.properties file:

message = User name (EN - US)

and the code fragment:

What is the result?

    Correct Answer: D

    The program sets the default locale to Locale.US. Then it explicitly sets the current locale to a new Locale with the language set to 'en'. When ResourceBundle attempts to find the appropriate properties file, it will look for the most specific match first and go broader if it doesn't find more specific ones. Since 'user' is specified in Captions_en.properties as 'User name (EN)', and it matches the selected locale, the result will be 'User name (EN)'.

Discussion
SampsOption: D

D is correct