Core Java - Interview Questions and Answers for 'Dateformat' | Search Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

Search Interview Questions


 More than 3000 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

   



Core Java - Interview Questions and Answers for 'Dateformat' - 4 question(s) found - Order By Newest

 Q1. Which of the following code is correct ?

a. DateFormat df = DateFormat.getInstance();
b. DateFormat df = DateFormat.getDateInstance();
c. DateFormat df = DateFormat.getInstance(DateFormat.FULL);
d. DateFormat df = DateFormat.getDateInstance(DateFormat.FULL);
Core Java
Ans. All except c are correct.

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

   Like         Discuss         Correct / Improve     java   date   dateformat


 Q2. What is the use of parse method in DateFormat ?
Ans. It is used to parse String to get the Date Object with initialized date.

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

   Like         Discuss         Correct / Improve     java   date   dateformat


 Q3. Which of the following code is correct ?

a. Date date = DateFormat.newInstance(DateFormat.LONG, Locale.US).parse(str);

b. Date date = DateFormat.newInstance(DateFormat.LONG, Locale.US).format(str);

c. Date date = DateFormat.getDateInstance(DateFormat.LONG, Locale.US).parse(str);
Core Java
Ans. c

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

   Like         Discuss         Correct / Improve     java   java.util   date   dateformat


 Q4. 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);

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



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: