The (default) properties file "mymsgs.properties" is present, so the code will create a bundle based on that file.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().
None of the answers listed is correct, because on my machine the code prints
Code: Select all
cancelLabel : Cancel
okLabel : OK
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:
Kind regards,The program may print:as we cannot be sure of the actual print orderCode: Select all
cancelLabel : Cancel okLabel : OK
Martijn