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

Creating and Iterating through Arrays Arrays are a data structure that allow a p

ID: 3701299 • Letter: C

Question

Creating and Iterating through Arrays Arrays are a data structure that allow a programmer to reference multiple data items through the same variable name, using an index to specify which one. Arrays in Java are declared using square brackets after the variable name [1. To declare an array of ints called myints, you would write: intl myInts: Q1 How would you declare an array of doubles called myDoubles? Arrays can be initialized in one of two ways. In one method, the array elements are placed in a list enclosed in curly braces after the array name definition. For example, the code below creates an array of ints with 3 elements: 1, 2 and 3. intl a-, 2, 3 We can also initialize an array with a new construct, indicating how many elements we want with a number inside square brackets, as in the exampl double b new double [341 When this type of initialization is used, the values of the array are initialized to zero for numeric types, and null for object types Q2) What values would the elements of the following array have initially? intll q new int [991: Q3) What values would the elements of the following array have initially? String[ s-new String[101

Explanation / Answer

Solution:

The first four subparts have been answered as per Chegg guidelines, please repost others.

we can declare in two ways

double[] myDouble;

another way is

double myDouble[]; // I hope we are talking about Java here

2)

They all will be initialized with 0 initially. //This is the property of java

3)

All will be pointing to NULL.

4)

in the loop before print we have to add the below statement

a[i]++;

or a[i]+= 1;

I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)

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