Question: 7. What is the output during execution if the user types in bdcda as input? char ch1=' '; int j = 0; for(int i =
7. What is the output during execution if the user types in "bdcda" as input? char ch1=' '; int j = 0; for(int i = 0 ; i < 5; i++) { try { ch1 = (char) System.in.read(); } catch(Exception e) {} if (ch1 == 'a') break; else if (ch1 == 'b') continue; else if (ch1 == 'c') i--; else if (ch1 == 'd') j++; j++; } System.out.println( j );
8. What value is returned when method func(9) is invoked? public double SquareRoot( double value ) throws ArithmeticException { if (value >= 0) return Math.sqrt( value ); else throw new ArithmeticException(); } public double func(int x) { double y = (double) x; y *= -9.0; try { y = SquareRoot( y ); } catch(ArithmeticException e) { y /= 3; } finally { y += 10; } return y; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
