Which two code blocks correctly initialize a Locale variable?

Which two code blocks correctly initialize a Locale variable?

Which two code blocks correctly initialize a Locale variable?

A.
Locale loc1 = “UK”;

B.
Locale loc2 = Locale.getInstance(“ru”);

C.
Locale loc3 = Locale.getLocaleFactory(“RU”);

D.
Locale loc4 = Locale.UK;

E.
Locale loc5 = new Locale(“ru”, “RU”);

Explanation:

The Locale class provides a number of convenient constants that you can use to create Locale
objects forcommonly used locales.
For example, the following creates a Locale object for the United States:
Locale.US
E: Create a Locale object using the constructors in this class:
Locale(String language)
Locale(String language, String country)
Locale(String language, String country, String variant)
Reference: java.utilClass Locale



Leave a Reply 2

Your email address will not be published. Required fields are marked *