READ Free Dumps For Oracle- 1z0-803
Question ID 21923 | Given the code fragment:
interface SampleClosable {
public void close () throws java.io.IOException;
}
Which three implementations are valid?
|
Option A | public class Test implements SampleCloseable {
Public void close () throws java.io.IOException {
/ / do something
}
}
|
Option B | public class Test implements SampleCloseable {
Public void close () throws Exception {
/ / do something
}
}
|
Option C | public class Test implementations SampleCloseable {
Public void close () throws Exception {
/ / do something
}
}
|
Option D | public class Test extends SampleCloseable {
Public void close () throws java.IO.IOException {
/ / do something
}
}
|
Correct Answer | D |
Explanation Explanation: To declare a class that implements an interface, you include an implements clause in the class declaration. One interface might extended another interface, but a class cannot extend an interface. Checked exceptions are subject to the Catch or Specify Requirement. All exceptions are checked exceptions, except for those indicated by Error, RuntimeException, and their subclasses.
Question ID 21924 | Given the code fragment:
Int [] [] array = {{0}, {0, 1}, {0, 2, 4}, {0, 3, 6, 9}, {0, 4, 8, 12, 16}}; Systemout.printIn(array [4] [1]);
System.out.printIn (array) [1][4]);
int [] [] array = {{0}, {0, 1}, {0, 2, 4}, {0, 3, 6, 9}, {0, 4, 8, 12, 16}}; System.out.println(array [4][1]);
System.out.println(array) [1][4]);
What is the result?
|
Option A | 4
Null
|
Option B | Null
|
Option C | An IllegalArgumentException is thrown at run time
|
Option D | 4
An ArrayIndexOutOfBoundException is thrown at run time
|
Correct Answer | D |
Explanation Explanation: The first println statement, System.out.println(array [4][1]);, works fine. It selects the element/array with index 4, {0, 4, 8, 12, 16}, and from this array it selects the element with index 1, 4. Output: 4 The second println statement, System.out.println(array) [1][4]);, fails. It selects the array/element with index 1, {0, 1}, and from this array it try to select the element with index 4. This causes an exception. Output: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4