SCJP Module-12 Question-3


 

SCJP Module-12 Question-3

The Sample program given below will test your understanding about the Locale class of the Java.

The Sample program given below will test your understanding about the Locale class of the Java.

Given  :

dd is non-null object of Date
datef is set to the current locale (non-null DateFormat object)

Which code lines outputs the current locale's country name and the appropriate version of dd's date?

1. Locale lc = Locale.getLocale();

   System.out.println(lc.getDisplayCountry()+ " " + datef.format(dd));

2. Locale lc = Locale.getDefault();

    System.out.println(lc.getDisplayCountry()+ " " + datef.format(dd));

3. Locale lc = Locale.getLocale();

    System.out.println(lc.getDisplayCountry()+ " " + datef.setDateFormat(dd));

4. Locale lc = Locale.getDefault();

    System.out.println(lc.getDisplayCountry() + " " + datef.setDateFormat(dd));

Answer

(2)

Ads