intro to java course The answer is: 1 1 not a number 1 I am unsure how to get th
ID: 3736852 • Letter: I
Question
intro to java course
The answer is:
1 1 not a number
1
I am unsure how to get that. Any help greatly appreciated
6) Given the classes below, show the output of the following program execution: public class SmallNumberException extends Exception public class test //Sets up exception object with a particular message. static public void main (Stringl) args) SmalNumberException (String message) final int MIN-0; Stringl) values-("7", "3", "this", "5" SmallNumberException problem-new SmallNumberException( Too sm super (message); all." for (int i-0;kvalues.length;i+) try if (Integer.parselnt(values[il)Explanation / Answer
For i = 0,
values[0] = 7 > MIN
So, the if is not executed. So, it prints 7 % 2 = 1
For i = 1,
values[0] = 3 > MIN
So, the if is not executed. So, it prints 3 % 2 = 1
For i = 2,
values[2] = this
Now, this can't be converted to integer. hence, it throws a NumberFormatException. So, the second catch block is executed, it prints not a number.
For i = 3,
values[0] = 5 > MIN
So, the if is not executed. So, it prints 5 % 2 = 1
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.