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.USE: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
D and E are correct answers.
Answer is D & E
+1
D, E