Trouble Flashcards
ArithmeticException
Runtime or Checked Exception?
Runtime Exception
ArrayIndexOutOfBoundsException
Runtime or Checked Exception?
Runtime Exception
ClassCastException
Runtime or Checked Exception?
Runtime Exception
IllegalArgumentException
Runtime or Checked Exception?
Runtime Exception
NullPointerException
Runtime or Checked Exception?
RuntimeException
NumberFormatException
Runtime or Checked Exception?
Runtime Exception
FileNotFoundException
Runtime or Checked Exception?
Checked Exception
IOException
Runtime or Checked Exception?
Checked Exception
Does StringBuilder test for object equality or same letters with the .equals() method?
Object Equality
The type of the object determines…
which properties exist within the object in memory
The type of the reference to the object determines…
which methods and variables are accessible to the java program
What can you not do with the Period class?
Chain methods!
How to define an ArrayList that can have different types in it
ArrayList differentTypes = new ArrayList()
I guess just don’t specify type
Can you override the finalize() method?
Yes
Cab you pass null to varargs?
yes, but trying to access an index will result in NullPointerException
For LocalDate d, is there a difference between
d.minus(p)
and
d = d.minus(p)
Yes.
You must do d = d.minus(p);
If using a variable name as one of the cases in a switch statement, what modifier must it have?
final
Note: watch out for a final variable having the same value as a literal in the cases!
Does System.gc() guarantee garbage collection will run?
No, it just hints at it
What is wrong with this?
List list = new List()
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()
Can you have calls to both super() and this() in a constructor?
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.