Share on Google+Share on Google+

SCJP Module-12 Question-9

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

Given below the sample code :

1 // import class here
2 public class dateclass {
3 public static void main(String args[]){
4 Locale locale = Locale.getDefault();
5 System.out.println(locale);
6 locale = new Locale("fr", "CA");
7 Locale.setDefault(locale);
8 System.out.println(locale);
9 DateFormat df = DateFormat.getDateInstance();
10 Date myDate = new Date();
11String myString = df.format(myDate);
12 System.out.println(myString);
13 }
14 }

In the above code , errors are at lines 4,6,7 & 10 ,Which class need to 'import' at line 1 to correct these errors ?

 1. import java.text.*;

2. import java.lang.Object;

3. import java.util.*;

4. import java.io.*;

Answer

(3)

Explanation

The "java.util" class contains the definition of "locale" and "date".

Advertisements

Posted on: July 22, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial 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.