ch6 Flashcards

1
Q

Can you change the value of a java.time.LocalDateTime object?

A

No. It’s immutable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

d = new java.time.LocalDateTime(); What happens?

A

compiler error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

int numbers []; What’s the result?

A

The array numbers is declared. [] right to the name and space between: not recommended, but legal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

int[3] places; What’s the result?

A

Compile error. It is illegal to include the array’s size in the declaration.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

x[-2] What’s the result if x is an array?

A

ArrayIndexOutOfBoundsException

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can you determine the size of an array or ArrayList?

A

array: length attribute; ArrayList: size() method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Can an ArrayList hold primitives?

A

No. Only objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What happens if casting is not successful?

A

ClassCastException. No compiler error!!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly