Java ResourceBundle Example - Localizing Application with Properties File

Valid Keys for menu1: File Menu

Question

You have been asked to create a ResourceBundle which uses a properties file to localize an application.

Which code example specifies valid keys of menu1 and menu2 with values of File Menu and View Menu?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

D.

The correct answer is B:

php
<key>menu1</key><value>File Menu</value> <key>menu2</key><value>View Menu</value>

ResourceBundle is a Java class that is used to internationalize an application by loading locale-specific resources. In other words, it allows you to load text and other resources from a file that is specific to a user's language and region.

The properties file is a text file that contains key-value pairs. Each key-value pair represents a resource that can be localized. The keys are used to identify the resource, while the values are the actual resource content.

To specify valid keys of menu1 and menu2 with values of File Menu and View Menu, we need to use the correct syntax for the properties file. The correct syntax for the properties file is:

makefile
key=value

Therefore, option A is incorrect because it uses an invalid syntax. The <key> and <value> tags are not used in a properties file.

Option C is incorrect because it also uses an invalid syntax. It has comma-separated values, which is not valid for a properties file.

Option D is also incorrect because it is missing the equal sign between the key and the value.

Option B is the correct answer because it uses the correct syntax for a properties file. It defines the key and value pairs for menu1 and menu2 as "menu1=File Menu" and "menu2=View Menu", respectively.