nerdexam
Oracle

1Z0-804 · Question #95

Given three resources bundles with these values set for menu1: (the default resource bundle in US English.) English US Resource Bundle Menu1 = small French Resource Bundle Menu1 = petit Chinese…

The correct answer is D. A runtime error is produced. Compiles fine, but runtime error when trying to access the Spanish Resource bundle (which Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name messageBundle, locale es_ES

Localization

Question

Given three resources bundles with these values set for menu1: (the default resource bundle in US English.) English US Resource Bundle Menu1 = small French Resource Bundle Menu1 = petit Chinese Resource Bundle Menu1 = And given the code fragment:

Locale.setDefault(new Locale("es", "ES")); // Set default to Spanish and Spain Locale loc1 = Locale.getDefault(); ResourceBundle message = ResourceBundle.getBundle("MessageBundle", loc1); System.out.println(message.getString("menu1")); What is the result?

Options

  • ANo message is printed
  • Bpetit
  • Csmall
  • DA runtime error is produced

How the community answered

(52 responses)
  • A
    10% (5)
  • B
    13% (7)
  • C
    6% (3)
  • D
    71% (37)

Explanation

Compiles fine, but runtime error when trying to access the Spanish Resource bundle (which Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name messageBundle, locale es_ES

Topics

#ResourceBundle#locale fallback#MissingResourceException#bundle lookup

Community Discussion

No community discussion yet for this question.

Full 1Z0-804 Practice