Page 1 of 1

About Question enthuware.ocpjp.v8.2.1769 :

Posted: Mon Oct 12, 2015 5:09 am
by Martyjee
The explanation contains the following:
The code is trying to create a resource bundle for a specific locale i.e. en_IN. To create this bundle, mymsgs_en_IN.properties must be present in the classpath. Since this file is not available, the resource bundle cannot be created. An exception will therefore be thrown when you call getBundle().
The (default) properties file "mymsgs.properties" is present, so the code will create a bundle based on that file.

None of the answers listed is correct, because on my machine the code prints

Code: Select all

cancelLabel : Cancel
okLabel : OK
So the character '=' listed in the options should be replaced with ':'.

Furthermore, the order of the elements cannot be determined because the ResourceBundle in this example is actually an instance of PropertyResourceBundle, which maintains a HashMap to store its items! The getKeys() method of this example returns the HashMap's keySet(). The order of its elements can thus not be determined at compile time!

The correct answer should therefore be:
The program may print:

Code: Select all

cancelLabel : Cancel
okLabel : OK
as we cannot be sure of the actual print order
Kind regards,

Martijn

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

Posted: Mon Oct 12, 2015 10:39 pm
by admin
You are right. Fixed.
thank you for your feedback!