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

 
 

SCJP Module-12 Question-5
Posted on: July 20, 2010 at 12:00 AM
The Sample program will test your understanding about the Locale Class in Java.

Given below the sample code :

1  import java.text.*;
2  import java.util.*;
3  public class dateclass {
4  public static void main(String args[]){
5  Locale locale = Locale.getDefault();
6  System.out.println(locale);
7  // Insert code here
8  System.out.println(locale);
9  DateFormat df = DateFormat.getDateInstance();
10 Date myDate = new Date();
11 String myString = df.format(myDate);
12 System.out.println(myString);}}

What will be at line 7 to print date in locale of Canada(French) ?

1. locale = new Locale("fr", "CA");
    Locale.setDefault(locale);

2. df.setLocale(Locale.CA);

3. locale = new Locale("fr", "CA");
    Locale.getDefault(locale);

4. locale = new Locale("fr", "CA");
    Locale.getLocale(locale);

Answer

(1)

 

Related Tags for SCJP Module-12 Question-5:


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.