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

 
 

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

Advertisement

Related Tags for SCJP Module-12 Question-9:


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 22, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com