What will the following code do ?<br/><br/>String dateStr = "2011 11 19";<br/>DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");<br/>Date date = dateFormat.parse(dateStr);<br/>System.out.println(date);<br/> <br/> DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = dateFormat.parse(dateStr);
System.out.println(date);

">DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = dateFormat.parse(dateStr);
System.out.println(date);

">
Javasearch.buggybread.com

Search Interview Questions


 3372 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Java - Interview Questions and Answers

 Q1. What will the following code do ?

String dateStr = "2011 11 19";
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = dateFormat.parse(dateStr);
System.out.println(date);

admin
info@buggybread.com
Ans. It will throw the ParseException as the date format doesn't abide with the format of the specified date.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     date   utility classes   dateformat   exception   parseexception


Related Questions

  What are the ways to avoid LazyInitializationException ?
  What things should be kept in mind while creating your own exceptions in Java?
  Explain java.lang.OutOfMemoryError ?
  How compiler handles the exceptions in overriding ?
  If you are given a choice to implement the code to either Insert a Record or Update if already exist, Which approach will you follow ?
  Explain throw, throws , try and catch in Java ?
 What will happen if we don't have termination statement in recursion ?
  Name few Java Exceptions ?
  How can we make sure that a code segment gets executed even in case of uncatched exceptions ?
  Is it necessary that each try block to be followed by catch block ?



Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: