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

 
 

SCJP Module-12 Question-6
Posted on: July 22, 2010 at 12:00 AM
The Sample code given below will test your understanding about the Date, DateFormate classes in Java and will also check how the formate the Date in Java.

Given below the sample code :

1. Date dt = new Date();
2. String ds = ?December 21, 2009″;
3. // insert code here
4. try {
5. dt = datef.parse(ds);
6. }
7. catch(ParseException pe) {
8. System.out.println(?Unable to parse ? + ds);
9. }
10. // insert code here

Which code lines should add at line number 3 and 10 to add a day to the Date object?

1. 3.   DateFormat datef = DateFormat.getDateFormat();
    10. dt.setTime( (60 * 60 * 24) + dt.getTime());
2. 3.   DateFormat datef = DateFormat.getDateInstance();
    10. dt.setTime( (1000 * 60 * 60 * 24) + dt.getTime());
3. 3.   DateFormat datef = DateFormat.getDateFormat();
    10. dt.setLocalTime( (1000*60*60*24) + dt.getLocalTime());
4. 3.   DateFormat datef = DateFormat.getDateInstance();
    10. dt.setLocalTime( (60 * 60 * 24) + dt.getLocalTime());

Answer

(2)

 


Related Tags for SCJP Module-12 Question-6:


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.