Multiple choice technology programming languages

Is this Legal? Class ExceptionA extends Exception {} class ExceptionB extends ExceptionA {} public class Test{ void thrower() throws ExceptionA{ throw new ExceptionA(); } public static void main(String[] args){ Test t = new Test(); try{t.thrower();} catch(ExceptionB e) {} } }

  1. True

  2. False

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The code is illegal because ExceptionA is a checked exception thrown by thrower(). The try block only catches ExceptionB, which is a subclass of ExceptionA. Since the superclass exception ExceptionA is neither caught nor declared in the main method's signature, the code fails to compile.