Page 1 of 1
About Question enthuware.ocpjp.v8.2.1154 :
Posted: Mon Feb 20, 2017 5:27 am
by runnerdave
I don't understand the answer, it says:
While retrieving a message bundle, you are passing a locale explicitly (fr CA)
But the question clearly says:
where the default locale is English - US
Why do they say that the locale is passed explicitly?
Thanks
Re: About Question enthuware.ocpjp.v8.2.1154 :
Posted: Mon Feb 20, 2017 7:15 am
by admin
The default locale of the machine is given as English-US. But the code is using fr CA in this line: Locale.setDefault(new Locale("fr", "CA"));
Re: About Question enthuware.ocpjp.v8.2.1154 :
Posted: Mon May 15, 2017 11:50 am
by lenalena
The question is confusing because the actual names of the files are not given. If the "French CA resource bundle file" has the wrong naming convention, then there will be an exception.
Re: About Question enthuware.ocpjp.v8.2.1154 :
Posted: Mon May 15, 2017 11:50 pm
by admin
A resource bundle file can be a resource bundle file only if it satisfies all the conditions of a valid resource bundle file. So if "French CA resource bundle file" has a wrong name, it will not be a "French CA resource bundle file" , right?
-Paul.
Re: About Question enthuware.ocpjp.v8.2.1154 :
Posted: Tue May 16, 2017 8:45 am
by lenalena
There could be an unintentional typo and it could be a trick question. Usually the questions (on the exam as well, as much as I can judge by the OCA) state that one can "assume correct imports" or "assume correct file names". That's why when there was no "assume correct resource bundle file names" it felt a little ... off.
Re: About Question enthuware.ocpjp.v8.2.1154 :
Posted: Wed Sep 28, 2022 1:42 pm
by sohamdatey22
Let's say the default bundle is "en_US"
1. ResourceBundle rb = ResourceBundle.getBundle("test", new Locale("hi","IN"));
Bundle selection order :
test_hi_IN ---> test_hi ---> test_en_US ---> test_en ---> test.
Property search Order :
a. if bundle selected is test_hi_IN.properties, the property will be searched in:
test_hi_IN.properties ----> test_hi.properties--->test.properties
b. if bundle selected is test_hi.properties, the property will be searched in :
test_hi.properties---->test.properties
c. if bundle selected is test_en_US.properties(default), the properties will be searched in.
test_en_US.properties ---->test_en.properties---->test.properties
d. if the bundle selected is test_en.properties, the properties will be searched in
test_en.properties--->test.properties
e. if the bundle selected is test.properties, the properties will be searched in
test.properties
this implies the bundle search happens, first.
then when the property search happens it does not leave the locale heirarchy.