Given the code fragment:
Assume that the system date is June 20, 2014. What is the result?
A. Option A
B. Option B
C. Option C
D. Option D
Given the code fragment:
Assume that the system date is June 20, 2014. What is the result?
A. Option A
B. Option B
C. Option C
D. Option D
A
public static void main(String[] args) {
LocalDate date1= LocalDate.now();
LocalDate date2 = LocalDate.of(2014,6,20);
LocalDate date3= LocalDate.parse(“2014-06-20”, DateTimeFormatter.ISO_DATE);
System.out.println(date1);
System.out.println(date2);
System.out.println(date3);
this question asks “do you know how ISO format of date looks like” 😀
Answer A:
There is no reason for the compilation to fail or to get any exception. Code will look like as stated in A.
Correct answer is A, it won’t throw a parse exception because 2014-06-20 in indeed in ISO format. Tested with netbeans