class Exception2{ public static void main(String args[]){ try{ /* SuperOne so = new SuperOne(); so.setVar(-5); System.out.println(so.getVar()); */ SuperTwo st = new SuperTwo(); st.setSO(-5); System.out.println(st.so.getVar()); }catch(oneException oe){ oe.printStackTrace(); }catch(Exception e){ e.printStackTrace(); }//catch }//main }//Exception2 class oneException extends RuntimeException{ public oneException(String message){ super(message); System.out.println(message); } }//oneException class SuperOne{ int var; SuperOne(){} public void setVar(int v){ if(v < 0) throw new oneException("Something wrong."); else var = v; }//setV1 public int getVar(){ return var; }//getV1() }//SuperOne class SuperTwo{ SuperOne so; SuperTwo(){ so = new SuperOne(); } public void setSO(int i) throws oneException{ so.setVar(i); }//setSO() }//SuperTwo