Saturday, October 10, 2020

write a java program for demonstration of Finally block

 class Finally1 

{

public static void main(String[] args) 

{

int data =20;

//case 4:finally block not exceuted when use the following method

System.exit(0);

try

{

int c=data/0;

System.out.println("c value is"+c);

}

finally

{

System.out.println("Finally block exceuted");

}

System.out.println("rest of the code exceuted");

}

}


No comments:

Post a Comment