Public static void myQ8 (string x) { boolean done = false: int i = 4: string nam
ID: 3858442 • Letter: P
Question
Public static void myQ8 (string x) { boolean done = false: int i = 4: string name = x: while (! done) { try { char c = name.charAt(i): i = i + 2: System.out.print ln ("n-" +c): done = true: } catch (IndexOutOfBoundsException exception) { System.out.println ("Error Caught 123"): } catch (Exception exception) { System.out print In ("Happy Holidays"): i = 0: } i++: } System.out. println ("Good bye " + i): } what is printed after calling myQ8 ("BIOL101"): a. n - 1 Good bye 7 b. Good bye 1 c. Happy Holidays d. Infinite loop Answer: what is printed after calling myQ8 ("ask"): a. Happy Holidays Good bye 2 b. Good bye 2 c. Infinite Loop with "Error Cauqhtl23" d. None of the above Answer:Explanation / Answer
Q9: As the CharAt index 4 is present and is "1" ,
so the answer will be
n=1
Good Bye 7
Q10. As the character at index 4 is not present, the value of boolean variable done will always remain false and the program willg o into the infinite loop and print nothing. So the answer will be
d. None of the above
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.