What is the result?

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?

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?

A.
No message is printed

B.
Petit

C.
A runtime error is produced

Explanation:
There is no Spanish resource bundle. The following runtime error will occur:

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 *


Charlie

Charlie

The default Resource Bundle has been changed to ES but there’s no ES.

Peter

Peter

C, MissingResourceException