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:
D:The Locale class provides a number of convenient constants that you can use to create Locale objects for commonly 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 4

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


Yury

Yury

D and E are correct answers.