Topic: 1z0-819 topic 1 question 147

Which two assignments create Locale instances? (Choose two.)

A.
locale = “fr_FR”;
B.
locale = “en-USA”;
C.
locale = new Locale(“en”, “GB”);
D.
locale = Locale.getAvailableLocales();
E.
locale = Locale.getDefault();

Re: 1z0-819 topic 1 question 147

Tested CE D return [] of Locale

Re: 1z0-819 topic 1 question 147

answer : C
Actually
D.  locale = Locale.getAvailableLocales()
E. locale = Locale.getDefault();
They are both not created new instances
They just return already existed one.

Re: 1z0-819 topic 1 question 147

D. locale = Locale.getAvailableLocales()
It could be
Locale[] locale = Locale.getAvailableLocales()

Re: 1z0-819 topic 1 question 147

Tested: CE.

Re: 1z0-819 topic 1 question 147

Option C creates a new Locale instance using the Locale constructor that takes two arguments: a language code and a country code. In this case, the language code is "en" for English and the country code is "GB" for Great Britain.Option E creates a Locale instance by calling the static method Locale.getDefault(), which returns the default Locale for the current instance of the Java Virtual Machine.