Trouble Flashcards

1
Q

ArithmeticException

Runtime or Checked Exception?

A

Runtime Exception

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

ArrayIndexOutOfBoundsException

Runtime or Checked Exception?

A

Runtime Exception

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

ClassCastException

Runtime or Checked Exception?

A

Runtime Exception

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

IllegalArgumentException

Runtime or Checked Exception?

A

Runtime Exception

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

NullPointerException

Runtime or Checked Exception?

A

RuntimeException

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

NumberFormatException

Runtime or Checked Exception?

A

Runtime Exception

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

FileNotFoundException

Runtime or Checked Exception?

A

Checked Exception

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

IOException

Runtime or Checked Exception?

A

Checked Exception

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

Does StringBuilder test for object equality or same letters with the .equals() method?

A

Object Equality

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

The type of the object determines…

A

which properties exist within the object in memory

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

The type of the reference to the object determines…

A

which methods and variables are accessible to the java program

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

What can you not do with the Period class?

A

Chain methods!

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

How to define an ArrayList that can have different types in it

A

ArrayList differentTypes = new ArrayList()

I guess just don’t specify type

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

Can you override the finalize() method?

A

Yes

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

Cab you pass null to varargs?

A

yes, but trying to access an index will result in NullPointerException

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

For LocalDate d, is there a difference between

d.minus(p)

and

d = d.minus(p)

A

Yes.

You must do d = d.minus(p);

17
Q

If using a variable name as one of the cases in a switch statement, what modifier must it have?

A

final

Note: watch out for a final variable having the same value as a literal in the cases!

18
Q

Does System.gc() guarantee garbage collection will run?

A

No, it just hints at it

19
Q

What is wrong with this?

List list = new List()

A

List is an interface, so it cannot be instantiated directly!

Basically it can only be on the left side of this equation and you would want

List list = new ArrayList()

20
Q

Can you have calls to both super() and this() in a constructor?

A

No, only one or the other. One way to reason this is that any call to super() or this() must be the first non-comment line in a constructor, and they can’t both go first.