public static void main(String[] args) {
   try {
     sw.on();
     // Code that can throw exceptions...
     sw.off();
   } catch (NullPointerException e) {
     System.out.println("NullPointerException");
     sw.off();
   } catch (IllegalArgumentException e) {
     System.out.println("IOException");
     sw.off();
   }
 }
 public static void main(String[] args) {
   try {
     sw.on();
     // Code that can throw exceptions...
     f();
     sw.off();
   } catch (OnOffException1 e) {
     System.out.println("OnOffException1");
     sw.off();
   } catch (OnOffException2 e) {
     System.out.println("OnOffException2");
     sw.off();
   }
 }