Question

Question 21 What will be the results after the following code is executed? int[] arrayi = new int [25]; // Code that will put

0 0
Add a comment Improve this question Transcribed image text
Answer #1

After the above code is executed the result will be:

value contains the lowest value in array1.

​​​​

Explanation:

Let's consider the array1 contains following values [4, 7, 1, 3, 8]

value = array1[0] = 4

Iteration-1

for(a=1 and 1<5 is true)

array[1]<value i.e, 7<4 is false

So the control goes back to for loop

Iteration-2

a++; i.e, 1++

for(2<5 is true)

array1[2]<value i.e, 1<4 is true

So, value = array1[2] = 1

Iteration-3

​​​2++;

for(2<5 is true)

array1[3]<value i.e, 3<1 is false

The control goes back to the for loop

Iteration-4

3++;

for(4<5 is true)

array1[4]<value i.e, 8<1 is false

The control goes back to the for loop

Iteration-5

4++;

for(5<5 is false)

So the control comes out of for loop

And the value = 1(lowest value in array1).

You can refer the executed code with it's output given in the pictures below.

Execute > Share Source File STDIN import java.util.Scanner; public class HelloWorld 10 public static void main(String [jargs)Execute > Share Source File STDIN 32 87 43 19 16 54 35 69 46 47 31 67 34 82 67 11 34 90 56 54 76 3 45 67 87 Il Result $javac

Add a comment
Know the answer?
Add Answer to:
Question 21 What will be the results after the following code is executed? int[] arrayi =...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT