diff --git a/Doc/Sd1/Appendix/Exam/2023/Summer/exam.xml b/Doc/Sd1/Appendix/Exam/2023/Summer/exam.xml index f8e04de04c3961cd2b63e05b6ded01442f30014d..85cd3937155262a21db7e4be50c8267b914ab9e4 100644 --- a/Doc/Sd1/Appendix/Exam/2023/Summer/exam.xml +++ b/Doc/Sd1/Appendix/Exam/2023/Summer/exam.xml @@ -27,7 +27,8 @@ <listitem> <para>Open this project in your <productname>IDEA</productname> IDE - by selecting the <filename>Exam/pom.xml</filename> file.</para> + by selecting the <filename>Exam/pom.xml</filename> file. Your home + directory is <filename>/home/student</filename>.</para> </listitem> </orderedlist> </section> @@ -172,7 +173,26 @@ <para>So the <code language="java">switch</code> statement implementing a jump table differs from <code>if ... else if</code> in definitely calling <code - language="java">computeItemCount()</code> only once.</para> + language="java">computeItemCount()</code> only once. In order to + be in full accordance we'd need a small modification for the + »<code language="java">if</code>« implementation:</para> + + <programlisting language="java">public static int getScore() { + + final int itemCount = computeItemCount(); + + if (1 == itemCount) { + return 20; + } else if (3 == itemCount) { + return 50; + } else { + return 0; + } +}</programlisting> + + <para>This way both implementations are in complete sync. (At + least despite runtime efficiency and possible <link + xlink:href="https://freedocs.mi.hdm-stuttgart.de/doc/openjdk-17-doc/api/java.base/java/lang/OutOfMemoryError.html">OutOfMemoryError</link>s)</para> </answer> </qandaentry> </qandadiv> @@ -247,6 +267,13 @@ try { } catch (<link xlink:href="https://freedocs.mi.hdm-stuttgart.de/doc/openjdk-17-doc/api/java.base/java/lang/RuntimeException.html">RuntimeException</link> e) { // Common parent class System.err.println(e.getMessage()); }</programlisting> + + <para>Caveat: There is a <link + xlink:href="https://freedocs.mi.hdm-stuttgart.de/doc/openjdk-17-doc/api/java.base/java/lang/RuntimeException.html#class-description">whole + bunch of other child classes</link> of <link + xlink:href="https://freedocs.mi.hdm-stuttgart.de/doc/openjdk-17-doc/api/java.base/java/lang/RuntimeException.html">RuntimeException</link>. + The simplified version thus potentially catches additional + exceptions we might not be aware of. </para> </answer> </qandaentry> </qandadiv>