Java OCA OCP Practice Question 2102

Question

Fill in the blank so the code correctly compiles and creates a Locale.

Locale loc = Locale.___; 
A.   get("Italian")
B.   get(Locale.ITALIAN)
C.   getLocale("Italian")
D.   None of the above


D.

Note

There is no get() method on Locale.

You need to use a constructor or a predefined Locale constant to obtain a Locale object.

Option D is the correct answer.

Option B is close in that Locale.ITALIAN does reference a Locale object.

However, it should not be passed to the nonexistent get() method.




PreviousNext

Related