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

 
 

SCJP Module-12 Question-9
Posted on: July 22, 2010 at 12:00 AM
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".

Related Tags for SCJP Module-12 Question-9:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.