educative.io

Educative

https://www.educative.io/courses/learn-java-from-scratch/3jjPkQpWnkO

Hi,
I don’t understand question 2, I could not figure out how the answer is: false true false. Can you explain to me how this question is solved?
Thanks,


Type your question above this line.

Course: https://www.educative.io/collection/10370001/5138612588904448
Lesson: https://www.educative.io/collection/page/10370001/5138612588904448/5696838413844480

Hi @Elbekjon_Bakhronbeko

On line 1, we declare a new boolean array of size 3. By default, each element is assigned a value of false, so the array looks like [false, false, false].

On line 2, we assign the first element a value of false, since arr.length == 2 evaluates to false. On line 3, we assign the second element a value of true, since arr.length == 3 evaluates to true. The array now looks like [false, true, false].

Hope this helped!