Task 1. What kind of errors are is caused by the following code, if any? How would we fix them?
View the step-by-step solution to:

Question


Capture.PNG



/>



Task 1. What kind of errors are is caused by the following code, if any? How would we fix them? Note: Some errors may be caused before execution (before you run the program). In this case, list the error written in NetBeans when you hover over the problem.

                       

           Task 1a.

                       String[] arr = new String[10];

          arr[10] = "This is a String";

          Exception: __________

                                   

                       What caused the error: __________

 

                      How to Fix It: __________

                                   

                                   

                                   

           Task 1b.

                       String[] arr = new String[-1];

                       

Exception: __________

                                   

                       What caused the error: __________

 

                      How to Fix It: __________

                                   

           Task 1c.

                       String arr = new String[10];

                       

                       Exception: __________

                                   

                       What caused the error: __________

 

                      How to Fix It: __________

                                   

                                   

           Task 1d.

               String[] arr = new String[10];

          System.out.println(arr[2].length());

 

                       Exception: __________

                                   

                       What caused the error: __________

 

                      How to Fix It: __________

                                   

           Task 1e.

                       Object x[] = new String[1];

          x[0] = new Integer(0);

 

                       Exception: __________

                                   

                       What caused the error: __________

 

                      How to Fix It: __________

                                   

                                   

           Task 1f.

                       String arr[] = new String[10];

 

                       Exception: __________

                                   

                       What caused the error: __________

 

                      How to Fix It: __________





Capture1.PNG






Capture2.PNG

                                   

                                   

 

Capture.PNG

Capture1.PNG

Capture2.PNG

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes