Which two codes correctly represent a standard language locale code?
A.
ES
B.
FR
C.
U8
D.
Es
E.
fr
F.
u8
Explanation:
Language codes are defined by ISO 639, an international standard that assigns two- and threeletter codes tomost languages of the world. Locale uses the two-letter codes to identify the target
language.
All language tags in ISO 639 are in lower-case. Please refer to:
http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
Therefore, if D is “es”, then answer should be D E (F is not correct – “u8” is not defined in the standard).
Locale[] locales = SimpleDateFormat.getAvailableLocales();
for (Locale locale : locales) System.out.println(locale.getLanguage());
This prints a huge list of two-letter lower-case language codes. “fr” is printed. “u8” isn’t printed though.
Javadoc for “getLanguage”:
Returns the language code of this Locale.
Note: ISO 639 is not a stable standard— some languages’ codes have changed. Locale’s constructor recognizes both the new and the old codes for the languages whose codes have changed, but this function always returns the old code. If you want to check for a specific language whose code has changed, don’t do
es, fr