Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question: b.) i.) numberFormatException ii.) ArrayIndexOutofBoundException iii.)

ID: 3549928 • Letter: Q

Question

Question:



b.) i.) numberFormatException
      ii.) ArrayIndexOutofBoundException

      iii.)IllegalArgumentException


Please check my b answer,
amd c how to do, using comment to explain?






What exception type does the following statement throws? String message = "hello"; System.out.printIn(message.charAt (5)); double [] array = new double [7]; System.out.printIn(array [7] ); JButton bt; bt.setText ("Submit"); Write a statement to draw a circle with radius 15 centered at coordinates 40, 40 (given g is the Graphics object).

Explanation / Answer

i) String message = "hello";
    System.out.println(message.charAt(5));

trying to access 5 which is out of bound so Exception is ArrayIndexOutofBoundException

ii) double[] array = new double[7];
System.out.println(array[7]);

trying to access 7 which is out of bound so Exception is ArrayIndexOutofBoundException

iii) JButton bt;
bt.setText("submit");

NullPointerException because bt object not initialized.

c) statement to draw circle with radius 15 centered at (40,40) given g

drawCircle(g, 40, 40, 5);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote