Computer Tips and Tricks

Saturday, October 10, 2020

write a java program for creating own exception

class InvalidageExeption extends Exception 

{

InvalidageExeption(String s)

{

super(s);

}

}



class TestException 

{

static void validate(int age) throws InvalidageExeption

{

if(age<18)

throw new InvalidageExeption("not valid");

}

public static void main(String[] args) throws InvalidageExeption

{

validate(13);


}

}

 

Posted by vamsinath at 8:20 AM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

About Me

vamsinath
View my complete profile

Blog Archive

  • ▼  2020 (63)
    • ▼  October (12)
      • write python turtle program to draw letter E
      • write python turtle program for creating Archimede...
      • write a python program for creating a class Studen...
      • write a python program for creating class person w...
      • write a java program for demonstration of Finally ...
      • write a java program for exception propagation
      • write a java program for creating own exception
      • write a java program creating static variables?
      • write a java program using throw keyword ?
      • write a java program for generating arithmetic exc...
      • write a java program demonstrating relationship be...
      • write a java program for exhibiting multiple inher...
    • ►  August (24)
    • ►  May (26)
    • ►  April (1)
  • ►  2019 (1)
    • ►  February (1)
Simple theme. Powered by Blogger.