Question: What is output? public class MathOps { public static int divOp ( int num, int denom ) throws Exception { if ( denom = =

What is output?
public class MathOps {
public static int divOp(int num, int denom) throws Exception {
if (denom ==0){
throw new Exception("Invalid div input");
}
return num / denom;
}
public static double sqrtOp(double num) throws Exception {
if (num <0){
throw new Exception("Invalid sqrt input");
}
return Math.sqrt(num);
}
public static void main(String[] args){
try {
int x;
int y;
x =4;
y =0;
System.out.println(divOp(x, y));
System.out.println(sqrtOp((double)y));
}
catch (Exception excpt){
System.out.println(excpt.getMessage());
System.out.println("Cannot compute operation");
}
}
}
a.
Invalid div input
Invalid sqrt input
b.
Invalid div input
Cannot compute operation
c.
Invalid div input
Invalid sqrt input
Cannot compute operation
d.
Cannot compute operation

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!