Home Tutorial Java Scjp Part12 SCJP Module-12 Question-2


Share on Google+Share on Google+
SCJP Module-12 Question-2
Posted on: July 20, 2010 at 12:00 AM
The sample program given below will check your knowledge about the DataFormate class in Java.

Given below the sample code :

11 DateFormat df = DateFormat.getDateInstance();
12 Date date = new Date();
13 df.setLocale(Locale.ITALY);
14 String str = df.format(date);
15 System.out.println(str);

What will be the output of the above code?

1. current date

2. no output

3. compile error at line 13

4. current date and country name.




Wrong way of setting Locale. The method setLocale(Locale) is undefined for the type DateFormat.


Related Tags for SCJP Module-12 Question-2:

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 20, 2010

Recommend the tutorial

Advertisements Advertisements