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
About Question enthuware.ocpjp.v8.2.1154 :
Moderator: admin
-
- Posts: 12
- Joined: Mon Jan 30, 2017 2:58 pm
- Contact:
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1154 :
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"));
If you like our products and services, please help us by posting your review here.
-
- Posts: 56
- Joined: Tue Feb 21, 2017 4:24 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1154 :
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.
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1154 :
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.
-Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 56
- Joined: Tue Feb 21, 2017 4:24 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1154 :
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.
-
- Posts: 28
- Joined: Sun Sep 11, 2022 3:55 am
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1154 :
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.
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.
Who is online
Users browsing this forum: No registered users and 39 guests