Unit 5: Java Date and Time API - Subjective Questions

CSE406 — Advanced Java Programming • Practice Questions with Detailed Answers

20 questions

1

Explain the purpose and key features of the Java Date and Time API introduced in Java 8.

2

Describe how to create and manage date-based events using the LocalDate class.

3

Explain how time-based events are created and managed using the LocalTime class.

4

Compare LocalDate and LocalTime with respect to their purpose, stored information, and common applications.

5

Explain how a date and time are combined into a single object using LocalDateTime.

6

Distinguish between LocalDateTime, OffsetDateTime, and ZonedDateTime.

7

Describe how Java handles dates and times across different time zones using ZoneId and ZonedDateTime.

8

Explain the difference between withZoneSameInstant() and withZoneSameLocal() with a suitable example.

9

Define an instant and explain how the Instant class is used to represent timestamps.

10

Differentiate between an Instant and a LocalDateTime.

11

Define a period and explain how the Period class is used for date-based calculations.

12

Define a duration and explain how the Duration class differs from Period.

13

Compare Period.between() and Duration.between() and state when each should be used.

14

Explain how DateTimeFormatter is used to format and parse local dates and times.

15

Describe important pattern symbols used by DateTimeFormatter for formatting dates and times.

16

Explain how local and zoned date-times are formatted differently.

17

Explain the role of ZoneOffset and UTC in date-time programming.

18

Describe how daylight-saving transitions can affect date-time calculations and explain how Java handles them.

19

Explain how to calculate the duration between two timestamps and why Instant is suitable for this task.

20

Discuss the immutability and thread safety of the Java Date and Time API classes.