GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  J2EE  >  Core Java

 Print  |  
Question:  Please Give me an example for User defined Exception



November 11, 2005 06:36:05 #5
 nagaraju.balla   Member Since: Visitor    Total Comments: N/A 

RE: Please Give me an example for User defined Excepti...
 

class NoMoneyException extends Exception{

       public NoMoneyException(String m){super(m);}}

       public class Bank {

      public static void main(String[] args) throws NoMoneyException{

      int b=5000,wd=15000;

    if(b>wd){System.out.println("Enjoy");}

  else {throw new NoMoneyException("Insufficient Money Exception");}

 }}

         



 

     

 

Back To Question