Java OCA OCP Practice Question 2969

Question

Choose the best option based on this program:

import java.util.Locale;

public class Main {
     public static void main(String []args) {
             Locale locale = new Locale("navi", "pandora");  //#1
             System.out.println(locale);
     }
  }
A.the program results in a compiler error at statement #1.
B.the program results in a runtime exception of NoSuchLocaleException.
C.the program results in a runtime exception of MissingResourceException.
D.the program results in a runtime exception of IllegalArgumentException.
e.the program prints the following: navi_panDora.


e.

Note

to create a Locale object using the constructor Locale(String language, String country), any String values can be passed.

Just attempting to create a Locale object will not result in throwing exceptions other than a NullPointerException, which could be raised for passing null Strings.

the toString() method of Locale class returns a string representation of the Locale object consisting of language, country, variant, etc.




PreviousNext

Related