Search Header Logo

Dates and Times

Authored by Kevin Tinsley

Instructional Technology

University

Used 5+ times

Dates and Times
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

11 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

When compared with the new date/time API that was introduced with Java 8, what is an advantage of the old date/time API?

It’s thread-safe.

It’s intuitive.

It’s easier to localize for parts of the world that don’t use the Gregorian calendar.

It works with versions of Java prior to Java 8.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What package stores the LocalDateTime class?

java.util

java.text

java.time

java.date

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is true about a LocalDate object?

It represents a date only.

It works from the observer’s perspective.

It represents a time only.

Both a and b.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

If the current time is 5pm, what is printed to the console? LocalTime now = LocalTime.now(); LocalTime startTime = LocalTime.of(15, 30); if (now.compareTo(startTime) < 0) { System.out.println("early"); } else if (now.compareTo(startTime) > 0) { System.out.println("late"); } else if (now.compareTo(startTime) == 0) { System.out.println("on time"); }

early

late

on time

nothing

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following statements gets the month from a LocalDate object named now?

int month = now.getMonth();

int month = now.getMonthInt();

Month month = now.getMonth();

Month month = now.getMonthInt();

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Given a LocalDate object named date, which of the following statements changes the day of the month to the 12th?

LocalDate newDate = date.withDayOfMonth(12);

LocalDate newDate = date.setDayOfMonth(12);

LocalDate newDate = date.withDay(12);

LocalDate newDate = date.setDay(12);

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Given a LocalDateTime object named now that stores the current date and time, which of the following statements gets a new LocalDateTime object that’s four weeks in the future?

LocalDateTime newDateTime = now.incrementWeeks(4);

LocalDateTime newDateTime = now.addWeeks(4);

LocalDateTime newDateTime = now.plusWeeks(4);

LocalDateTime newDateTime = now.plus(WEEKS, 4);

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?