Java APIs Flashcards Preview

Java 1z0-808 Maya > Java APIs > Flashcards

Flashcards in Java APIs Deck (14)
Loading flashcards...
1
Q

The date and

time classes have private constructors to force you to use the static methods.

A

Don’t fall for this. You are not allowed to construct a date or time object directly

2
Q

LocalDate

A

Contains just a date—no time and no time zone

2015-01-20

3
Q

LocalTime

A

Contains just a time—no date and no time zone.

12:45:18.401

4
Q

LocalDateTime

A

Contains both a date and time but no time zone
2015-01-20T12:45:18.401

Java uses T to
separate the date and time when converting LocalDateTime to a String.

5
Q

You need an import statement to work with the date and time classes.

A

import java.time.*;

6
Q

Autoboxing

A
Since Java 5, you can just type the primitive value and Java will convert it to the
relevant wrapper class for you. This is called autoboxing.
7
Q

The parse methods, such as parseInt(), return a primitive

A

the valueOf() method returns a wrapper class

8
Q

MMMM

A

M represents the month. The more Ms you have, the more verbose the Java output.
For example, M outputs 1, MM outputs 01, MMM outputs Jan, and MMMM outputs January.

9
Q

dd

A

d represents the date in the month. As with month, the more ds you have, the more
verbose the Java output. dd means to include the leading zero for a single-digit month.

10
Q

yyyy

A

y represents the year. yy outputs a two-digit year and yyyy outputs a four-digit year.

11
Q

mm

A

m represents the minute.

12
Q

ISO is a standard for dates.

A

DateTimeFormatter.ISO_LOCAL_DATE
2020-01-20

DateTimeFormatter.ISO_LOCAL_TIME
11:12:34

DateTimeFormatter.ISO_LOCAL_DATE_TIME
2020-01-20T11:12:34
(T separates date from time)

13
Q

rules to know

A
  1. If both operands are numeric, + means numeric addition.
  2. If either operand is a String, + means concatenation.
  3. The expression is evaluated left to right.
14
Q

Immutability

A

An object that can’t be changed once it’s created. String is immutable.

Mutable is another word for changeable.