Given:
and
and
You want to print the message こんにちは Joe, 宜しくお願いします, Jane.
Which code inserted on line 1 will accomplish this?
Given:
and
and
You want to print the message こんにちは Joe, 宜しくお願いします, Jane.
Which code inserted on line 1 will accomplish this?
To print the message こんにちは Joe, 宜しくお願いします, Jane, you need to correctly load the Japanese resource bundle and format the message. The correct code should access the resource bundle using the fully qualified class name and match the correct locale. The array notation should be correct to hold the names, and the parameters passed to MessageFormat should be directly referencing the loaded message. The correct code to achieve this is: ResourceBundle msg = ResourceBundle.getBundle(“msg.messages”, Locale.JAPAN); Object[] names = {“Joe”, “Jane”}; String message = MessageFormat.format(msg.getString(“message”), names);. This ensures the proper resource bundle is used and the message is formatted correctly with the given names.
Tested. No answer is correct. A, B and D because of line "String[] names = "Joe", "Jane");" - compilation failed. C is almost correct if we put: String message = MessageFormat.format(message.getString(“message”),“Joe”,“Jane”); instead of: String message = MessageFormat.format(msg.getString(“message”),“Joe”,“Jane”);
A,C,D A is also correct. see spec : "Note:The baseName argument should be a fully qualified class name. However, for compatibility with earlier versions, Sun's Java SE Runtime Environments do not verify this, and so it is possible to access PropertyResourceBundles by specifying a path name (using "/") instead of a fully qualified class name (using ".")."
C is correct. there are syntax errors on the others (closing parenthesis). .... "Joe","Cane")
A is not valid first argument must be qualified name . all other are ok.
D is the correct answer if you have your language set properly