Skip to main content

Posts

Showing posts from May, 2025
 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(); } } }
 package SHIV; //Method Overradding (Run time Polymorphisam) public abstract class ATax { // Main Business ( Class)  public String tax(int sal)  { int tax=0;   int asal=sal*12;   if(asal<=250000)    tax=0;   else if(asal>250000 && asal<=500000)   {    tax=((asal-250000)*10)/100;   }   else if(asal>500000 && asal<=1000000)   {    tax=25000+((asal-500000)*20)/100;   }   else if(asal>1000000 && asal<=2000000)   {    tax=125000+((asal-1000000)*30)/100;   }   return "ATAX--->"+tax;  } }