Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 147

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

    Correct Answer: C, E

    The creation of Locale instances in Java can be done using the Locale constructor or by calling specific methods that return a Locale instance. Option C uses the constructor `new Locale(“en”, “GB”)` which directly creates a new Locale instance representing English in Great Britain. Option E uses the method `Locale.getDefault()`, which returns the default Locale instance for the current Java Virtual Machine. Options A and B do not correctly instantiate Locale objects as they simply assign strings. Option D calls a method that returns an array of Locale instances, not a single Locale instance.

Discussion
OmnisumemOptions: CE

Tested: CE.

StavokOptions: CE

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.

cathDevOptions: CE

Tested CE D return [] of Locale

ASPushkinOption: C

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

ASPushkinOption: D

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