What is the result?

Given three resource bundles with these values set for menu1: ( The default resource bundle is written in US English.) English US resource Bundle
Menu1 = small
French resource Bundle
Menu1 = petit
Chinese Resource Bundle
Menu = 1

And given the code fragment:
<code>
Locale.setDefault (new Locale(“es”, “ES”)); // Set default to Spanish and Spain
loc1 = Locale.getDefault();
ResourceBundle messages = ResourceBundle.getBundle (“messageBundle”, loc1);
System.out.println (messages.getString(“menu1”));
</code>
What is the result?

Given three resource bundles with these values set for menu1: ( The default resource bundle is written in US English.) English US resource Bundle
Menu1 = small
French resource Bundle
Menu1 = petit
Chinese Resource Bundle
Menu = 1

And given the code fragment:
<code>
Locale.setDefault (new Locale(“es”, “ES”)); // Set default to Spanish and Spain
loc1 = Locale.getDefault();
ResourceBundle messages = ResourceBundle.getBundle (“messageBundle”, loc1);
System.out.println (messages.getString(“menu1”));
</code>
What is the result?

A.
No message is printed

B.
petit

C.
:

D.
Small

E.
A runtime error is produced

Explanation:
Compiles fine, but runtime error when trying to access the Spanish Resource bundle (which does not exist):
Exception in thread “main” java.util.MissingResourceException: Can’t find bundle for base name messageBundle, locale es_ES



Leave a Reply 0

Your email address will not be published. Required fields are marked *