Java OCA OCP Practice Question 3202

Question

Consider the following program:

import java.io.*;
import java.sql.*;

public class Main {
       public static void fooThrower() throws FileNotFoundException {
               throw new FileNotFoundException();
       }//from   w  w  w .  j a  va 2 s .c o m
       public static void barThrower() throws SQLException {
               throw new SQLException();
       }
       public static void main(String []args) {
               try {
                       fooThrower();
                       barThrower();
               } catch(FileNotFoundException || SQLException multie) {
                       System.out.println(multie);
               }
       }
}

Which one of the following options correctly describes the behavior of this program?

  • A. This program prints the following: java.io.FileNotFoundException.
  • B. This program prints the following: java.sql.SQLException.
  • C. This program prints the following: java.io.FileNotFoundException || java.sql.SQLException.
  • D. This program fails with compiler error(s).


D.

Note

For multi-catch blocks, the single pipe (|) symbol needs to be used and not double pipe (||), as provided in this program.

Hence this program will fail with compiler error(s).




PreviousNext

Related