Q.– Given the code fragment:
LocalDate datel = LocalDate.now();
LocalDate date2 = LocalDate.of (6, 20, 2014);
LocalDate date3 = LocalDate.parse("2014-06-20", DateTimeFormatter. ISO_DATE);
System.out.println("date1 = " + date1);
System.out.println("date2 = " + date2);
System.out.println("date3 = " + date3);
Assume that the system date is June 20, 2014.
What is the result?
A) Compilation fails.
B) date1 = 2014-06-20
date2 = 2014-06-20
date3 = 2014-06-20
C) date1 = 06/20/2014
date2 = 2014-06-20
date3 = Jun 20, 2014
D) An exception is thrown at runtime.
⧪ please give your answer in a comment section.
LocalDate datel = LocalDate.now();
LocalDate date2 = LocalDate.of (6, 20, 2014);
LocalDate date3 = LocalDate.parse("2014-06-20", DateTimeFormatter. ISO_DATE);
System.out.println("date1 = " + date1);
System.out.println("date2 = " + date2);
System.out.println("date3 = " + date3);
Assume that the system date is June 20, 2014.
What is the result?
A) Compilation fails.
B) date1 = 2014-06-20
date2 = 2014-06-20
date3 = 2014-06-20
C) date1 = 06/20/2014
date2 = 2014-06-20
date3 = Jun 20, 2014
D) An exception is thrown at runtime.
⧪ please give your answer in a comment section.
3 Comments
a
ReplyDeleteA
ReplyDeleteat line LocalDate date2 = LocalDate.of (6, 20, 2014);
ReplyDeleteException in thread "main" java.time.DateTimeException: Invalid value for MonthOfYear (valid values 1 - 12): 20
Answer D