0 votes
in JAVA by
What is the output of the following Java program?

1 Answer

0 votes
by
class Calculation extends Exception  

{  

    public Calculation()   

    {  

        System.out.println("Calculation class is instantiated");  

    }  

    public void add(int a, int b)  

    {  

        System.out.println("The sum is "+(a+b));  

    }  

}  

public class Main{  

     public static void main(String []args){  

        try  

        {  

            throw new Calculation();   

        }  

        catch(Calculation c){  

            c.add(10,20);  

        }  

    }  

}   

Output

Calculation class is instantiated

The sum is 30

Explanation

Related questions

0 votes
asked Mar 24, 2021 in JavaScript by sharadyadav1986
+1 vote
asked Jun 2, 2020 in JAVA by Indian
...