About Question enthuware.ocpjp.v8.2.1868 :
Posted: Sun Dec 06, 2015 4:31 am
Answer of below question is wrong.
What will the following code print when run?
Period p = Period.between(LocalDate.now(), LocalDate.of(2015, Month.SEPTEMBER, 1)); System.out.println(p);
Duration d = Duration.between(LocalDate.now(), LocalDate.of(2015, Month.SEPTEMBER, 1)); System.out.println(d);
Assume that the local time on the system at the time this code is run is 2nd Sep 2015 1:00 AM.
Options Given:
1 : P-1D
PT-14H-50M
2 : P1D
PT9H10M
3 : P-1D
P-9H-10M
4:P1D
PT14H50M
5 : It will throw an exception at run time.
Answer Given : Option 5.
But when you will run same code in java editor it will print below answer.
P-1D
It will throw an exception at run time. (Exception in thread "main" java.time.temporal.UnsupportedTemporalTypeException: Unsupported unit: Seconds)
Means Option 5 is correct partially , Actual answer should be above (P-1D with exception) as you have give 2 system.out.println statement.
What will the following code print when run?
Period p = Period.between(LocalDate.now(), LocalDate.of(2015, Month.SEPTEMBER, 1)); System.out.println(p);
Duration d = Duration.between(LocalDate.now(), LocalDate.of(2015, Month.SEPTEMBER, 1)); System.out.println(d);
Assume that the local time on the system at the time this code is run is 2nd Sep 2015 1:00 AM.
Options Given:
1 : P-1D
PT-14H-50M
2 : P1D
PT9H10M
3 : P-1D
P-9H-10M
4:P1D
PT14H50M
5 : It will throw an exception at run time.
Answer Given : Option 5.
But when you will run same code in java editor it will print below answer.
P-1D
It will throw an exception at run time. (Exception in thread "main" java.time.temporal.UnsupportedTemporalTypeException: Unsupported unit: Seconds)
Means Option 5 is correct partially , Actual answer should be above (P-1D with exception) as you have give 2 system.out.println statement.