Advertisement
Guest User

Castes Inherited Exception catch Test

a guest
Oct 12th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.40 KB | None | 0 0
  1. import java.io.*;
  2. class RemoteException extends IOException
  3. {
  4. }
  5. class Foo{
  6.   public void ex() throws IOException{
  7.     throw new RemoteException();
  8.   }
  9. }
  10. class Main {
  11.   public static void main (String[] args){
  12.     try{
  13.       new Foo().ex();
  14.     }
  15.     catch(RemoteException rex){
  16.       System.out.println("yes");
  17.     }
  18.     catch(Exception ioe){
  19.       System.out.println("no");
  20.     }
  21.   }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement