Question: Which is output when inputVal is - 5 ? try { inputVal = scnr . nextInt ( ) ; if ( inputVal < 0 )

Which is output when inputVal is -5?
try {
inputVal = scnr.nextInt();
if (inputVal <0){
throw new Exception("Input should be positive");
}
System.out.print("Input squared: "+ inputVal * inputVal);
}
catch (Exception e){
System.out.print(e.getMessage());
}
Question 35 options:
Input squared: 25
Exception
Input should be positive
Input squared: 25
Input should be positive

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!