Given the code fragment:
What is the result?
Given the code fragment:
What is the result?
The code fragment defines and prints a Duration and a Period. Initially, a Duration of 5000 milliseconds is created, which equals to 5 seconds and will be printed as PT5S. Then the Duration is updated to 60 seconds, which equals to 1 minute and will be printed as PT1M. Finally, a Period of 6 days is printed as P6D. Therefore, the output of the program will be PT5SPT1MP6D.
Period: P#(Y,M,D) Duration: PT#(H, M, S) Result: PT5SPT1MP6D B is correct answer
B is correct
package q05; import java.time.Duration; import java.time.Period; public class Q05 { public static void main(String[] args) { Duration duration = Duration.ofMillis(5000); System.out.print(duration); duration = Duration.ofSeconds(60); System.out.print(duration); Period period = Period.ofDays(6); System.out.print(period); } } // Result: // PT5SPT1MP6D
B is correcct