Explore topic-wise MCQs in Java.

This section includes 6 Mcqs, each offering curated multiple-choice questions to sharpen your Java knowledge and support exam preparation. Choose a topic below to get started.

1.

How to get UTC time?

A. Time.getUTC();
B. Date.getUTC();
C. Instant.now();
D. TimeZone.getUTC();
Answer» D. TimeZone.getUTC();
2.

How to get difference between two dates?

A. long diffInMilli = java.time.Duration.between(dateTime1, dateTime2).toMillis();
B. long diffInMilli = java.time.difference(dateTime1, dateTime2).toMillis();
C. Date diffInMilli = java.time.Duration.between(dateTime1, dateTime2).toMillis();
D. Time diffInMilli = java.time.Duration.between(dateTime1, dateTime2).toMillis();
Answer» B. long diffInMilli = java.time.difference(dateTime1, dateTime2).toMillis();
3.

What does LocalTime represent?

A. Date without time
B. Time without Date
C. Date and Time
D. Date and Time with timezone
Answer» C. Date and Time
4.

How to identify if a timezone is eligible for DayLight Saving?

A. useDaylightTime() of Time class
B. useDaylightTime() of Date class
C. useDaylightTime() of TimeZone class
D. useDaylightTime() of DateTime class
Answer» D. useDaylightTime() of DateTime class
5.

Is SimpleDateFormat thread safe?

A. True
B. False
Answer» C.
6.

How to format date from one form to another?

A. SimpleDateFormat
B. DateFormat
C. SimpleFormat
D. DateConverter
Answer» B. DateFormat