Welcome Guest | Sign in | Register
Exceptions - Discussion Page For Q.2632 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Exceptions > Questions and Answers

Q: Given a valid DateFormat object named df, and

1. Date d = new Date(0L);

2. String ds = "December 15, 2004";

3. // insert code here

What updates d's value with the date represented by ds?
A. 3. d = df.parse(ds); B. 3. d = df.getDate(ds);
C. 3. try {
4. d = df.parse(ds);
5.} catch(ParseException e) { };
D. 3. try {
4. d = df.getDate(ds);
5.} catch(ParseException e) { };

Answer and Explanation

Answer:3. try {
4. d = df.parse(ds);
5.} catch(ParseException e) { };

Explanation:
Whenever you use parse( ) function it always throws ParseException. We have to enclose with try, catch block.
So C) is correct.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.