Given the four properties files, what does this code print?.
Cars_en.properties Cars_fr.properties engine=engine engine=moteur horses=123 Cars_en_US.properties Cars_fr_FR.properties country=US country=France
Locale.setDefault(new Locale("fr", "CA")); ResourceBundle rb = ResourceBundle.getBundle( "Cars", new Locale("en", "CA")); System.out.println(rb.getString("engine") + " " + rb.getString("horses"));
A. engine 123
B. moteur 123
C. moteur null
D. The code throws an exception at runtime.
A.
The getBundle()
method matches Cars_en.properties.
Since the requested locale of English Canada is not available, it uses the language-specific locale of English.
The engine key is in that properties file directly, so engine is retrieved as the value.
The horses key is also in that properties file, so 123 is used as the value, and Option A is the answer.