Question: Task 1: What kind of errors are is caused by the following code, if any? How would we fix them? //Task 1a. String[] arr =

Task 1: What kind of errors are is caused by the following code, if

any? How would we fix them?

//Task 1a.

String[] arr = new String[10];

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

1a. Error:__________________________________

1a. How to Fix

It:___________________________

---------------------------------------------

------------------------------

//Task 1b.

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

1b. Error:__________________________________

1b. How to Fix

It:___________________________

---------------------------------------------

------------------------------

//Task 1c.

String arr = new String[10];

1c. Error:__________________________________

1c. How to Fix

It:___________________________

---------------------------------------------

------------------------------

//Task 1d.

String[] arr = new String[10];

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

1d. Error:__________________________________

1d. How to Fix

It:___________________________

---------------------------------------------

------------------------------

//Task 1e.

String[] arr = new String[10];

arr[5] = 17;

1e. Error:__________________________________

1e. How to Fix

It:___________________________

---------------------------------------------

------------------------------

//Task 1f.

String arr[] = new String[10];

1f. Error:__________________________________

1f. How to Fix

It:___________________________

---------------------------------------------

------------------------------

Task 2:

Have the user store values in an array.

2a. Create a new Java project, and ask the user how many

values they would like to store.

2b. Initialize the global String array "data" using the

input as size

2c. Create a method called "populateArray" which will

contain a loop that asks the user to

input each value and store them

within the global array "data"

2d. Print the contents of the changed

array. Use a loop.

Task 3:

Have the user access or modify a value in the array.

3a. Create a method called "changeArray" which will ask

the user for an index (location) in the array

3b. Print out the value at the specified index

3c. Ask the user if they would like to change that value.

If so, get a value from the user and modify "data"

at the specified index to match the

user's input.

3d. Print the contents of the changed

array. Use a loop.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!