1Z0-809 · Question #187
Given the content: MessagesBundle.properties file: username = Enter User Name password = Enter Password MessagesBundle_fr_FR.properties file: username = Entrez le nom d'utilisateur password = Entrez…
The correct answer is A. username = Entrez le nom d'utilisateur password = Entrez le mot de passe. Option A is correct because the Locale is built with language "fr" and region "FR", which matches the MessagesBundle_fr_FR.properties file exactly - Java's ResourceBundle.getBundle() selects the most specific locale match available, so the French bundle takes precedence over…
Question
Options
- Ausername = Entrez le nom d'utilisateur password = Entrez le mot de passe
- Busername = Enter User Name password = Enter Password
- CA compilation error occurs.
- DThe program prints nothing.
How the community answered
(23 responses)- A74% (17)
- B9% (2)
- C13% (3)
- D4% (1)
Explanation
Option A is correct because the Locale is built with language "fr" and region "FR", which matches the MessagesBundle_fr_FR.properties file exactly - Java's ResourceBundle.getBundle() selects the most specific locale match available, so the French bundle takes precedence over the default.
Why the distractors fail:
- B is wrong because the default
MessagesBundle.propertiesis only used as a fallback when no locale-specific bundle matches - here,fr_FRmatches perfectly, so it's never reached. - C is wrong because this is valid Java code;
Locale.Builderis the modern API (Java 7+) for constructing locales, and all method calls here are correct. - D is wrong because the
Enumerationreturned bygetKeys()will contain both"username"and"password"keys, so the loop does execute and produces output.
Memory tip: Think of ResourceBundle as a search from most specific to least specific - it tries language_REGION, then language, then the default file. The first match wins, so a fully matching locale like fr_FR always beats the fallback.
Community Discussion
No community discussion yet for this question.