About Question enthuware.ocpjp.v8.2.1769 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
Martyjee
Posts: 32
Joined: Tue Oct 06, 2015 9:06 am
Contact:

About Question enthuware.ocpjp.v8.2.1769 :

Post 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

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

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

Post by admin »

You are right. Fixed.
thank you for your feedback!

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests