Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions