About Question enthuware.ocpjp.v8.2.1154 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
runnerdave
Posts: 12
Joined: Mon Jan 30, 2017 2:58 pm
Contact:

About Question enthuware.ocpjp.v8.2.1154 :

Post 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

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1154 :

Post 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"));
If you like our products and services, please help us by posting your review here.

lenalena
Posts: 56
Joined: Tue Feb 21, 2017 4:24 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1154 :

Post 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.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1154 :

Post 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.
If you like our products and services, please help us by posting your review here.

lenalena
Posts: 56
Joined: Tue Feb 21, 2017 4:24 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1154 :

Post 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.

sohamdatey22
Posts: 28
Joined: Sun Sep 11, 2022 3:55 am
Contact:

Re: About Question enthuware.ocpjp.v8.2.1154 :

Post 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.

Post Reply

Who is online

Users browsing this forum: No registered users and 39 guests