About Question enthuware.ocpjp.v7.2.1201 :
Moderator: admin
-
- Posts: 7
- Joined: Tue Apr 21, 2015 5:26 am
- Contact:
About Question enthuware.ocpjp.v7.2.1201 :
Is this question not ambiguous? This is also a valid answer, correct?
"MyResource_fr_CA.java"
"MyResource_fr_CA.java"
-
- Site Admin
- Posts: 10066
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1201 :
Why do you think it is ambiguous?
A .java file is supposed to contain java code, not properties.
A .java file is supposed to contain java code, not properties.
If you like our products and services, please help us by posting your review here.
-
- Posts: 12
- Joined: Thu Dec 11, 2014 12:32 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1201 :
but we can create resource bundle with ListResourceBundle
and save it as .java extension so I think MyResource_fr_CA.java option is also correct.
right?
and save it as .java extension so I think MyResource_fr_CA.java option is also correct.
right?
-
- Site Admin
- Posts: 10066
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1201 :
Assuming that you are talking about something similar to the example given here: http://docs.oracle.com/javase/7/docs/ap ... undle.html
no, it is still a java source file. It is not a resource bundle. It needs to be compiled into a class file.
HTH,
Paul.
no, it is still a java source file. It is not a resource bundle. It needs to be compiled into a class file.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 14
- Joined: Wed Oct 09, 2013 3:13 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1201 :
Hi,
I also found the answer rather confusing. If "MyResource_fr_CA.java" would be the correct answer what would be the wording of the question?
Bernhard
I also found the answer rather confusing. If "MyResource_fr_CA.java" would be the correct answer what would be the wording of the question?
Best regards,which of the following file names represents a valid (?)
Bernhard
-
- Site Admin
- Posts: 10066
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1201 :
Java source code file!
If you like our products and services, please help us by posting your review here.
-
- Posts: 16
- Joined: Fri Sep 04, 2015 5:06 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1201 :
Agree with the OP
why would you write a MyResource_fr_CA.java and not compile it?
I wonder if the OCP exam has such ambiguous questions.
why would you write a MyResource_fr_CA.java and not compile it?
I wonder if the OCP exam has such ambiguous questions.
-
- Site Admin
- Posts: 10066
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1201 :
No matter how you try to spin it, MyResource_fr_CA.java is not a resource bundle. You can create a resource bunding using it but the fact is MyResource_fr_CA.java is not a resource bundle. There is no ambiguity here.
If you like our products and services, please help us by posting your review here.
-
- Posts: 38
- Joined: Fri Nov 13, 2015 4:40 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1201 :
The contention is about the exact definition of "resource bundle".
I'm not sure whether MyResource_fr_CA.class would be considered one. However, the resource bundle is definitely the thing that the Java program accesses at run time, and the running program does not even look at the .java file. So no, the .java file is not a resource bundle, just as the .java file is not a class, it is something that will get compiled into a .class file.
I'm not sure whether MyResource_fr_CA.class would be considered one. However, the resource bundle is definitely the thing that the Java program accesses at run time, and the running program does not even look at the .java file. So no, the .java file is not a resource bundle, just as the .java file is not a class, it is something that will get compiled into a .class file.
-
- Posts: 8
- Joined: Wed Mar 16, 2016 10:57 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1201 :
Very confused here.
The following is an excerpt from OCA/OCP Java SE 7 Programmer I & II Study Guide (Exams 1Z0-803 & 1Z0-804):
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Locale locale = new Locale("fr", "CA");
ResourceBundle rb = ResourceBundle.getBundle("RB", locale);
Java will look for the following files in the classpath in this order:
RB_fr_CA.java //exactly what we asked for
RB_fr_CA.properties
//other files if previous weren't found
RB.java //couldn't find anything matching Locale, now trying default bundle
RB.properties
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
So how can this question make the claim that MyResource_fr_CA.java is not a valid resourcebundle file name?
Totally lost here.
Thanks
The following is an excerpt from OCA/OCP Java SE 7 Programmer I & II Study Guide (Exams 1Z0-803 & 1Z0-804):
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Locale locale = new Locale("fr", "CA");
ResourceBundle rb = ResourceBundle.getBundle("RB", locale);
Java will look for the following files in the classpath in this order:
RB_fr_CA.java //exactly what we asked for
RB_fr_CA.properties
//other files if previous weren't found
RB.java //couldn't find anything matching Locale, now trying default bundle
RB.properties
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
So how can this question make the claim that MyResource_fr_CA.java is not a valid resourcebundle file name?
Totally lost here.
Thanks
-
- Site Admin
- Posts: 10066
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1201 :
I think they meant "RB_fr_CA.class //exactly what we asked for". You should confirm with them.
Resource bundles are looked up in the class path. .java files don't reside in the class path. .class files do.
-Paul.
Resource bundles are looked up in the class path. .java files don't reside in the class path. .class files do.
-Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 97
- Joined: Wed Dec 28, 2016 9:00 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1201 :
For those who are confused with whether the answer should be
MyResource_fr_CA.java
I also got confused at it first but after reading the documentation it became clearer
To create the ResourceBundle, invoke the getBundlemethod, specifying the base name and Locale:
ResourceBundle labels = ResourceBundle.getBundle("LabelsBundle", currentLocale);
The getBundle method first looks for a class file that matches the base name and the Locale. If it can't find a class file, it then checks for properties files. In the PropertiesDemo program we're backing the ResourceBundle with properties files instead of class files. When the getBundle method locates the correct properties file, it returns a PropertyResourceBundle object containing the key-value pairs from the properties file.
That means if the option said
MyResource_fr_CA.class
then it would be correct since .class file will be considered first and if you are still wondering how a class file can be a resource file, then yes it can be done
by extending your class with ListResourceBundle. Look it up on google or a reference book to know the implementation details. Lucky I studied from Cay Hortsmann's Core Java(which I recommend everyone to refer not only for this exam but also for deep knowledge!).
MyResource_fr_CA.java
I also got confused at it first but after reading the documentation it became clearer
To create the ResourceBundle, invoke the getBundlemethod, specifying the base name and Locale:
ResourceBundle labels = ResourceBundle.getBundle("LabelsBundle", currentLocale);
The getBundle method first looks for a class file that matches the base name and the Locale. If it can't find a class file, it then checks for properties files. In the PropertiesDemo program we're backing the ResourceBundle with properties files instead of class files. When the getBundle method locates the correct properties file, it returns a PropertyResourceBundle object containing the key-value pairs from the properties file.
That means if the option said
MyResource_fr_CA.class
then it would be correct since .class file will be considered first and if you are still wondering how a class file can be a resource file, then yes it can be done
by extending your class with ListResourceBundle. Look it up on google or a reference book to know the implementation details. Lucky I studied from Cay Hortsmann's Core Java(which I recommend everyone to refer not only for this exam but also for deep knowledge!).
Who is online
Users browsing this forum: No registered users and 231 guests