ch6 Flashcards
1
Q
Can you change the value of a java.time.LocalDateTime object?
A
No. It’s immutable.
2
Q
d = new java.time.LocalDateTime();
What happens?
A
compiler error
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
4
Q
int[3] places;
What’s the result?
A
Compile error. It is illegal to include the array’s size in the declaration.
5
Q
x[-2]
What’s the result if x is an array?
A
ArrayIndexOutOfBoundsException
6
Q
How can you determine the size of an array or ArrayList?
A
array: length attribute; ArrayList: size() method
7
Q
Can an ArrayList hold primitives?
A
No. Only objects.
8
Q
What happens if casting is not successful?
A
ClassCastException. No compiler error!!