What is difference between checked exception and
Checked exceptions - checked by the
compiler, unchecked exceptions - Does not check by compiler.
- both exceptions - can use try-catch or throws
- Checked Exception - direct sub-Class of Exception, Unchecked
Exception - RuntimeException.
- CheckedException - scenario with higher failure rate,
UnCheckedException - mostly programming mistakes.
- CheckedException - IOException, SQLException,
ClassNotFoundException, UnCheckedException - NullPointerException,
What is defensive copy in java?
copying is a technique where an identical but disconnected, copy of
an object (including arrays) is returned instead of the original one.
Any modification to the returned object will not affect the original
private final List<Integer> values = new ArrayList<>();
private final List<Integer> immutableValues = Collections.unmodifiableList(values);
Generic is compile time or runtime in java?
Generics concept is introduced in Java language to provide tighter
type checks at compile time and to support generic programming.