Java OCA OCP Practice Question 281

Question

Given:

public class Main {
  public static void main(String[] args) {
    ResourceBundle rb = ResourceBundle.getBundle("Flag",
      new Locale("en_CA"));
    System.out.println(rb.getString("key"));
  }
}

Assume the default Locale is Italian.

If each of the following is the only resource bundle on the classpath and contains key=value.

which will be used?

Choose all that apply.

  • A. Flag.java
  • B. Flag_CA.properties
  • C. Flag_en.java
  • D. Flag_en.properties
  • E. Flag_en_CA.properties
  • F. Flag_fr_CA.properties


A, C, D, and E are correct.

Note

The default Locale is irrelevant here since none of the choices use Italian.

A is the default resource bundle.

C and D use the language but not the country from the requested locale.

E uses the exact match of the requested locale.

B is incorrect because the language code of CA does not match en.

And CA isn't a valid language code.

F is incorrect because the language code "fr" does not match en.




PreviousNext

Related