1Z0-819 · Question #184
Given config: MessageBundle.properties: username = Username password = Password and MessageBundle_fr_FR.properties: username = Utilisateur password = le passe and MessageBundle_ru.properties…
The correct answer is D. User = Utilisateur Pass = le passe E. User username. Option D is partially correct in that Locale.FRANCE resolves to fr_FR, so ResourceBundle.getBundle("MessageBundle", Locale.FRANCE) finds and loads MessageBundle_fr_FR.properties, returning "Utilisateur" for username. However, the stated answer key appears to contain an error…
Question
Options
- AUser = пользователь Pass = Пароль
- BThe compilation fails.
- CMissingResourceException is thrown at runtime.
- DUser = Utilisateur Pass = le passe
- EUser username
How the community answered
(39 responses)- A3% (1)
- B15% (6)
- C5% (2)
- D77% (30)
Explanation
Option D is partially correct in that Locale.FRANCE resolves to fr_FR, so ResourceBundle.getBundle("MessageBundle", Locale.FRANCE) finds and loads MessageBundle_fr_FR.properties, returning "Utilisateur" for username. However, the stated answer key appears to contain an error: new Locale("ru") resolves to MessageBundle_ru.properties, so msg_ru.getString("password") returns "Пароль" - not "le passe" as D claims. The actual output would be User = Utilisateur Pass = Пароль, which isn't cleanly represented by any single option as written (option E appears to be a corrupted/truncated distractor in this dump).
Why the other options are wrong:
- A is wrong on the
usernameside - "пользователь" is the Russian username, butmsguses the French (fr_FR) bundle, not the Russian one. - B is wrong - the code compiles fine;
ResourceBundle,Locale, andgetStringare all valid Java SE API calls. - C is wrong - both bundle files exist and both keys (
username,password) are present in them, so noMissingResourceExceptionis thrown.
Memory tip: Think of ResourceBundle.getBundle() as a "most specific match wins" lookup: it tries lang_COUNTRY → lang → default bundle in order, stopping at the first file found. Locale.FRANCE = fr_FR hits the _fr_FR file directly; new Locale("ru") (language-only) hits _ru directly - neither falls back to the default.
Community Discussion
No community discussion yet for this question.