Section 3 Exception and assertion
(Answer
all questions in this section)
1. What is
the definition of a logic error? Mark
for Review
Wrong
syntax that will be caught at compile time.
Bugs in
code that make your program run different than expected (*)
Computer
malfunction that makes your code run incorrectly.
Something
that causes your computer to crash.
2. Is this
the correct syntax for catching an exception?
Try(inputStream = "missingfile.txt");
Catch(exception e);
True or false?
True
False
(*)
3. Multiple
catch statements can be used for a single try statement.
True or false? Mark
for Review
True
(*)
False
4. When will
a finally statement be executed?
Mark for Review
Only if
an exception is thrown.
Only if
an exception is not thrown.
Always;
no matter if an exception is thrown or not. (*)
Only if
multiple exceptions are caught and thrown.
Never;
it is there for visual purposes.
5. What is
one step you must do to create your own exception? Mark for Review
Create
a new class that extends Exception. (*)
Create
a new class that implements Exception.
Declare
the primitive data type Exception.
Exceptions
cannot be created. They are only built in to Java.
6. What is
special about including a resource in a try statement? Mark for Review
(Choose
all correct answers)
The
resources will auto-close. (*)
The
program will fail if the resource does not open.
An
error will be thrown if the resources does not open. (*)
7. Assertions
are optional ways to catch logic errors in code.
True or false? Mark
for Review
True
(*)
False
8. When are
control flow invariants used? Mark for
Review
To test
run time errors in code.
To test
compilation errors in your code.
To test
specific variable values of your code.
To test
the correct flow of your code. (*)
The Golden Nugget Casino & Hotel | Henderson NV | KTNV
BalasHapusThe Golden Nugget Casino & 원주 출장샵 Hotel is 이천 출장샵 Henderson's premier 원주 출장안마 destination for entertainment and fine dining, featuring a variety 통영 출장마사지 of culinary 경산 출장마사지 offerings.