Multiple choice technology programming languages

public class test08 { public static void main(String[] args) { try{ A a = new B(); a.show(); }catch (Exception e){ } } }class A{ void show() throws FileNotFoundException{ System.out.println("This is the super class"); }}class B extends A{ void show() throws Exception{ System.out.println("This is the inherited class"); }}What will be the output?

  1. This is the super class

  2. This is the inherited class

  3. Compile time error

  4. Run time exception

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

This code fails to compile because of incompatible exception declarations in method overriding. When overriding a method, the subclass method cannot throw a broader checked exception than the parent class method. Here, the parent method throws FileNotFoundException, but the child class method throws Exception, which is broader. This violates Java's overriding rules and results in a compile-time error.