import java.io.*; import java.util.*; class ClassX { public void processFile(String fname) throws FileNotFoundException, InputMismatchException, NegativeIntegerException { Scanner inFile = new Scanner(new File(fname)); int x = inFile.nextInt(); inFile.close(); if (x < 0) throw new NegativeIntegerException(); System.out.println("Data is: " + x); } } class ClassY { public void processFile(String fname) throws FileNotFoundException { Scanner inFile = new Scanner(new File(fname)); int x = inFile.nextInt(); inFile.close(); System.out.println("Data is: " + x); } } class ClassZ extends ClassX { // ClassY public void processFile(String fname) throws FileNotFoundException, NegativeIntegerException { Scanner inFile = new Scanner(new File(fname)); int x = inFile.nextInt(); inFile.close(); if (x < 0) throw new NegativeIntegerException(); System.out.println("Data is: " + x); } } public class Main { public static void main(String[] args) { try { ClassZ p = new ClassZ(); p.processFile("1.txt"); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (NegativeIntegerException e) { e.printStackTrace(); } } }