Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GoikLectures
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Goik Martin
GoikLectures
Commits
1e2d9d63
Commit
1e2d9d63
authored
1 year ago
by
Goik Martin
Browse files
Options
Downloads
Patches
Plain Diff
Supplementary exception hints
parent
e89dcf3c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Doc/Sd1/Appendix/Exam/2023/Summer/exam.xml
+29
-2
29 additions, 2 deletions
Doc/Sd1/Appendix/Exam/2023/Summer/exam.xml
with
29 additions
and
2 deletions
Doc/Sd1/Appendix/Exam/2023/Summer/exam.xml
+
29
−
2
View file @
1e2d9d63
...
...
@@ -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>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment