public class CustomAgeExceptionn extends Exception{ CustomAgeExceptionn(){ } CustomAgeExceptionn(String s){ super(s); } public String checkAge(int a) throws CustomAgeExceptionn { if(a<18) { throw new CustomAgeExceptionn("You are not elagble for vote!!"); } else { return "Welcome !! "; } } public static void main(String[] args) { CustomAgeExceptionn ob=new CustomAgeExceptionn(); String s; try { s = ob.checkAge(20); System.out.println(s); } catch (CustomAgeExceptionn e) { e.printStackTrace(); } } }
TechOrbitAI is your go-to hub for the latest breakthroughs, trends, and insights in the world of technology and artificial intelligence. Whether you're a tech enthusiast, developer, entrepreneur, or just someone who loves staying ahead of the curve, TechOrbitAI delivers cutting-edge news, in-depth articles, expert opinions, and AI-powered insights—all in one orbit.