1Z1-804J Free Dumps Study Materials
Question 7: コ ード? フ ラグ メン トがあ りま す:
どのコ ード フラ グメ ント はラ ン*** で挿 入さ れ、 コンパ ル する コー ドを 有効に しま すか 。
A. public void process () throws FileNotFoundException, IOException { super.process ();
while ((record = br.readLine()) !=null) {
System.out.println(record);
}}
B. public void process () throws IOException {
super.process ();
while ((record = br.readLine()) != null) {
System.out.println(record);
}}
C. public void process () throws Exception {
super.process ();
while ((record = br.readLine()) !=null) {
System.out.println(record);
}}
D. public void process (){
try {
super.process ();
while ((record = br.readLine()) !=null) {
System.out.println(record);
}
} catch (IOException | FileNotFoundException e) { }
}
E. public void process (){
try {
super.process ();
while ((record = br.readLine()) !=null) {
System.out.println(record);
}
} catch (IOException e) {}
}
Correct Answer: E
Explanation:
A: Compilation fails: Exception IOException is not compatible with throws clause in Base.process()
B: Compilation fails: Exception IOException is not compatible with throws clause in Base.process()
C: Compilation fails: Exception Exception is not compatible with throws clause in Base.process()
D: Compilation fails: Exception FileNotFoundException has already been caught by the alternative IOException
Alternatives in a multi-catch statement cannot be related to subclassing Alternative java.io.FileNotFoundException
is a subclass of alternative java.io.IOException
E: compiles ...