Professional Documents
Culture Documents
jsp
21. The three logic operators in Java are: Mark for Review
(1) Points
&&, !=, =
!=, =, ==
&&, ||, ! (*)
&, |, =
Correct
Section 6
(Answer all questions in this section)
22. What are exceptions used for in Java? Mark for Review
(1) Points
Making the program easier to use for the user and reducing the possibilities of errors
occuring.
Helping the interpreter compile code quicker and handle user interfaces.
Exceptions have no use, they are just a part of the Java language.
Correcting mistakes made in your code and handling extraordinary cases. (*)
Correct
23. Which line of code shows the correct way to throw an exception? Mark for Review
(1) Points
throws new Exception("Array index is out of bounds");
new throw Exception("Array index is out of bounds");
throw new Exception("Array index is out of bounds"); (*)
throw Exception("Array index is out of bounds");
Correct
24. What exception message indicates that a variable may have been mispelled somewhere in the Mark for Review
program? (1) Points
variableName cannot be resolved to a variable (*)
method methodName(int) is undefined for the type className
Syntax error, insert ";" to complete statement
All of the above
Correct
25. It is possible to throw and catch a second exception inside a catch block of code. True or false? Mark for Review
(1) Points
True (*)
False
Correct