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]
2 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]2 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]2 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
(tco 8) when a file is opened in the append mode, the file pointer is positioned
Artyom0805 [142]
At the end of the file, so that additional data is appended while the existing data stays intact.
6 0
3 years ago
This operating system was used by individual computers and required users to type commands.
In-s [12.5K]

Answer:

MS-DOS is your answer

Explanation:

6 0
3 years ago
PLEASE HELP GIVING 25 POINTS Sophia is leading a project to help clean up a local river in her area. She creates an online forum
nignag [31]

Answer:

She holds useful online meetings

Explanation:

5 0
3 years ago
Read 2 more answers
Which of these is not one of the main parts of an email?
pav-90 [236]
The header is not a main part of the email. 
3 0
2 years ago
Read 2 more answers
When a switch is closed, completing an lr series circuit, the time needed for the current to reach one half its maximum value is
uysha [10]
The answer is <span>0.693 .  </span><span>When a switch is closed, completing an LR series circuit, the time needed for the current to reach one half its maximum value is 0.693   

</span>e^(-t/T) = 0.5 
<span>-t/T = ln(0.5) = -0.693 </span>
7 0
2 years ago
Other questions:
  • Again, consider what you believe to be the goal of performing a penetration test. Why would you worry about doing any privilege
    14·1 answer
  • Random-access memory (RAM) is able to quickly access data because it is arranged in which of the following configurations?
    8·2 answers
  • What type of device is built into a tablet computer and can send data over radio waves to another device such as a laser printer
    10·1 answer
  • A _______ record is responsible for resolving an ip to a domain name.
    9·1 answer
  • vulnerability is a feebleness which allows an attacker to condense a system's information assurance to security,is it true or fa
    14·1 answer
  • Which is the correct sequence of steps for opening a new document?
    10·2 answers
  • What is the purpose of a filename extension? How can you restore a file that you deleted from the hard disk?
    10·1 answer
  • When you copy a formula that contains an absolute reference to a new location, the reference ____. a. has a dotted outline in it
    6·1 answer
  • Heres the last questions
    5·1 answer
  • If you want Nud3s add me on sc Kermit4lyfe1
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!