1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
mario62 [17]
3 years ago
11

Assume that you have an array of integers named a. Which of these code segments print the same results?

Computers and Technology
2 answers:
Harrizon [31]3 years ago
4 0

Answer: II and III only

The first code will print starting with the second variable in the array. So it will start with array[1] instead of starting with array[0]

The second code will start from array[0] as the variable i is 0. It will print the first value in the array before proceeding to increment the value of i.

The third code will also start from array{0] as the program will check for the first value of a before proceeding to the next one.

An example would be if we were to define the array as:

int[] a = {1,2,3,4,5};

1st Code Output:

2

3

4

5

2nd Code Output:

1

2

3

4

5

3rd code Output:

1

2

3

4

5

Always remember that arrays will always begin from 0.

Zolol [24]3 years ago
3 0

Answer:

ii and iii only

Explanation:

<em>=> Analysis of the first code snippet;</em>

int i = 1;

while(i < a.length)

{

System.out.println(a[i]);

i++;

}

The code initializes the variable i to 1 and then loops from i=1 to one less than the length of the array a. At each of the loop, the corresponding element of the array at the index specified by the variable i is printed. And since i is starting at 1, the first element of the array (the one at index 0) will not be printed. Other elements in the array will be printed.

<em>=> Analysis of the second code snippet;</em>

int i;

for (i = 0; i < a.length; i++)

{

System.out.println(a[i]);

}

The code initializes the variable i to 0 and then loops from i=0 to one less than the length of the array a. At each of the loop, the corresponding element of the array at the index specified by the variable i is printed. And since i is starting at 0, the first element of the array (the one at index 0) will be printed. Other elements in the array will also be printed. In other words, all of the elements in the array will be printed.

<em>=> Analysis of the third code snippet;</em>

for (int i : a)

{

System.out.println(i);

}

The code uses the enhanced for version to print all the elements in the given array a. In the code each element in the array a is represented by i at various loop cycles. Therefore all the elements in the array a will be printed.

In summary, ii and iii will produce the same results.

You might be interested in
What is true about the dilation?
madreJ [45]

Hey hey hey! I recently took the test and the answer is D | (• ◡•)|

7 0
3 years ago
Read 2 more answers
List the seven basic internal components found in a computer tower
egoroff_w [7]
1. Motherboard (you plug all other components to it)
2. Processor (CPU)
3. Memory (RAM)
4. Graphics card
5. Sound card (sometimes integrated with motherboard)
6. Hard Disk Drive (HDD)
7. Power supply unit
6 0
3 years ago
Read 2 more answers
What is the diffrence between the the grassland and the savanna biomes
sergey [27]

Answer:

The term "savanna" is often used to refer to open grassland with some tree cover, while "grassland" refers to a grassy ecosystem with little or no tree cover.

Explanation:

5 0
3 years ago
Read 2 more answers
What kind of software would you recommend a company use if its employees are receiving e-mails that are potentially hazardous ?
scZoUnD [109]

Answer:

Microsoft project

Explanation:

I'm smart

6 0
3 years ago
Match each type of option on the left with a corresponding function on the right.
Marta_Voda [28]

Answer:

yes. the above is correct

Explanation: q posted

7 0
2 years ago
Other questions:
  • What is a geotag?
    10·1 answer
  • A city government is attempting to reduce the digital divide between groups with differing access to computing and the Internet.
    13·1 answer
  • Which program can damage your computer
    13·2 answers
  • How can a network design project benefit from the principles of itsm? How might itsm impede a network design project?
    11·1 answer
  • Why is the most important factor for investors always the quality of the venture's leadership team
    12·1 answer
  • Why is science, mathematics, and technology different from engineering?
    15·1 answer
  • Write a program that first reads in the name of an input file and then reads the input file using the file.readlines() method. T
    11·1 answer
  • How would you describe binary to someone ??<br> PLEASE ANSWER I WILL GIVE U BRAINLY!!
    15·2 answers
  • Molly needs to access a setting in microsoft windows group policy to change the type of a network to which a computer is attache
    15·1 answer
  • To create a datetime object for the current date and time, you can use theGroup of answer choicestoday() method of the date clas
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!