Java OCA OCP Practice Question 2233

Question

Consider the following program:

import java.io.FileNotFoundException;
import java.sql.SQLException;

public class Main {
     public static void fooThrower() throws FileNotFoundException {
         throw new FileNotFoundException();
     }/*  w w w  .  j  av  a 2s  .co 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