1Z0-851 · Question #97
Given: 1. d is a valid, non-null Date object 2. df is a valid, non-null DateFormat object set to the current locale What outputs the current locale's country name and the appropriate version of d's…
The correct answer is B. Locale loc = Locale.getDefault(); System.out.println(loc.getDisplayCountry() " " + df.format(d)). There is no getLocale method in class Locale. public static Locale getDefault() Gets the current value of the default locale for this instance of the Java Virtual Machine. The Java Virtual Machine sets the default locale during startup based on the host environment. It is used…
Question
Options
- ALocale loc = Locale.getLocale(); System.out.println(loc.getDisplayCountry() " " + df.format(d));
- BLocale loc = Locale.getDefault(); System.out.println(loc.getDisplayCountry() " " + df.format(d));
- CLocale loc = Locale.getLocale(); System.out.println(loc.getDisplayCountry() " " + df.setDateFormat(d));
- DLocale loc = Locale.getDefault(); System.out.println(loc.getDisplayCountry() " " + df.setDateFormat(d));
How the community answered
(22 responses)- A5% (1)
- B82% (18)
- C5% (1)
- D9% (2)
Explanation
There is no getLocale method in class Locale. public static Locale getDefault() Gets the current value of the default locale for this instance of the Java Virtual Machine. The Java Virtual Machine sets the default locale during startup based on the host environment. It is used by many locale-sensitive methods if no locale is explicitly specified. It can be changed using the setDefault method. Returns: the default locale for this instance of the Java Virtual Machine
Topics
Community Discussion
No community discussion yet for this question.