MCPcopy Create free account
hub / github.com/PrajaktaSathe/Java / main

Method main

Programs/nestedTry.java:5–25  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

3public class NestedTry {
4
5 public static void main(String[] args) {
6 int a = 20, b;
7 int ch[] = new int[20];
8 try {
9 b = a/0;
10 try {
11 System.out.println("Value of b = " + b);
12 }
13 catch(Exception e) {
14 System.out.println("Inner block Exception occured!");
15 }
16 }
17 catch(Exception e) {
18 System.out.println("Outer block exception occured!");
19 }
20 finally {
21 System.out.println("Quit");
22 System.out.println("This block will always execute!");
23 }
24 // finally block can be used to catch any exception
25 }
26}
27
28/* Note: Inner catch will use the outer catch block but outer catch will not use inner catch block exception

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected