Java OCA OCP Practice Question 2531

Question

Given the following code, which of the options will load resource bundle "foo_en_UK" for Locale.UK and assign it to the variable bundle?

The default language for the U.K. region is English (en).

ResourceBundle bundle = null;
a  bundle = ResourceBundle.getBundle("foo_en_UK.properties");
b  bundle = ResourceBundle.getListBundle("foo_en_UK");
c  bundle = ResourceBundle.getBundle("foo_en_UK.properties", Locale.UK);
d  bundle = ResourceBundle.getListBundle("foo_en_UK", Locale.UK);
e  bundle = ResourceBundle.getPropertyBundle("foo.properties");
f  bundle = ResourceBundle.getBundle("foo_en_UK", new Locale("en", "UK"));


f

Note

Options (b), (d), and (e) are incorrect because they use the nonexistent factory methods getListBundle() and getResourceBundle().

The correct and only factory method to retrieve a resource bundle is to call one of the overloaded methods, getBundle().

Options (a) and (c) are incorrect because the file extension ?.

properties' must not be included to load a resource bundle.




PreviousNext

Related