READ Free Dumps For Oracle- 1z0-803
Question ID 21921 | An unchecked exception occurs in a method dosomething() Should other code be added in the dosomething()
method for it to compile and execute?
|
Option A | The Exception must be caught
|
Option B | The Exception must be declared to be thrown.
|
Option C | The Exception must be caught or declared to be thrown.
|
Option D | No other code needs to be added.
|
Correct Answer | C |
Explanation Explanation: Valid Java programming language code must honor the Catch or Specify Requirement. This means that code that might throw certain exceptions must be enclosed by either of the following: * A try statement that catches the exception. The try must provide a handler for the exception, as described in Catching and Handling Exceptions. * A method that specifies that it can throw the exception. The method must provide a throws clause that lists the exception, as described in Specifying the Exceptions Thrown by a Method. Code that fails to honor the Catch or Specify Requirement will not compile.
Question ID 21922 | Given the code fragment:
int b = 4;
b -- ;
System.out.println (-- b);
System.out.println(b);
What is the result?
|
Option A | 2
|
Option B | 1
|
Option C | 3
|
Option D | 3
|
Correct Answer | A |
Explanation Explanation: Variable b is set to 4. Variable b is decreased to 3. Variable b is decreased to 2 and then printed. Output: 2 Variable b is printed. Output: 2