hw1: done
This commit is contained in:
parent
a912d72179
commit
3b72b84664
2 changed files with 18 additions and 14 deletions
BIN
hw1/answers.pdf
BIN
hw1/answers.pdf
Binary file not shown.
|
@ -23,38 +23,42 @@
|
|||
\item
|
||||
4: False (== for objects checks for reference equality)
|
||||
\item
|
||||
5: False (it is indeed implemented by default - i.e.~in Object, but
|
||||
the default implementation checks reference equality only)
|
||||
5: False (it is indeed implemented by default - more precisely implemented
|
||||
in Object - but the default implementation checks reference equality only)
|
||||
\item
|
||||
6: False (a child class of Tiger may include additional fields that
|
||||
6: False (a child class of \texttt{Tiger} may include additional fields that
|
||||
are mutable. However, all properties and behaviour accessible via a
|
||||
reference of Tiger type is immutable)
|
||||
reference of type \texttt{Tiger} type can be considered immutable)
|
||||
\item
|
||||
7: False (the class is not public)
|
||||
7: False (the class itself is not public)
|
||||
\item
|
||||
8: False (classes in the same package can read the name field)
|
||||
8: False (classes in the same package of \texttt{Tiger} can read the
|
||||
\texttt{name} field)
|
||||
\item
|
||||
9: True (the constructor to implement must explicitly call Tiger's
|
||||
constructor with super)
|
||||
9: True (the constructor to implement must explicitly call \texttt{Tiger}'s
|
||||
constructor with \texttt{super})
|
||||
\item
|
||||
10: False (the declared type is Number, the runtime type is Integer)
|
||||
10: False (the declared type is \texttt{Number}, the runtime type is
|
||||
\texttt{Integer})
|
||||
\end{itemize}
|
||||
|
||||
\section{Exercise B}
|
||||
|
||||
\begin{itemize}
|
||||
\item
|
||||
1: False (the only `collection' data structure based over an unboxed
|
||||
primitive type is the array)
|
||||
1: False (the only ``collection'' data structure based over an unboxed
|
||||
primitive type is the array -- however arrays are not \texttt{java.util}
|
||||
collections)
|
||||
\item
|
||||
2: True (if the hashCode() return value changes after the mutation then the
|
||||
implementation of hashMap is unable to recognize it was inserted previously)
|
||||
2: True (if the \texttt{hashCode()} return value changes after the mutation
|
||||
then the implementation of hashMap is unable to recognize it was inserted
|
||||
previously)
|
||||
\item
|
||||
3: True
|
||||
\item
|
||||
4: True
|
||||
\item
|
||||
5: False (finally blocks are always evaluated)
|
||||
5: False (\texttt{finally} blocks are always evaluated)
|
||||
\end{itemize}
|
||||
|
||||
\section{Exercise C}
|
||||
|
|
Reference in a new issue