What is the result?

Given three resource bundles with these values set for menu1: ( The default resource bundle is
written in US English.)
<code>
English US resource Bundle
Menu1 = small
French resource Bundle
Menu1 = petit
Chinese Resource Bundle
Menu = 1
And given the code fragment:
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:
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"));

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 2

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


Vasia

Vasia

D small
originally in resource menu1=…

The family should have a default resource bundle which simply has the same name as its family – “MyResources” – and will be used as the bundle of last resort if a specific locale is not supported.
so there is default resource bundle and it’s written in English

zoz

zoz

it is D,Vasia is right,