+ 1

Bug on "Java for Beginners Module 3 Quiz"

while using the sololearn app I came across this question "What's the output of this code?" "int arr[ ] = new int[3]; for (int i = 0; i < 3; i++) { arr = i; } int res = arr[0] + arr[2]; System.out.println(res);" Is that an error right? Can someone fix this please?

21st Nov 2024, 1:54 PM
Santi Covato
Santi Covato - avatar
5 Antworten
+ 3
i have reported this issue on 01.11.2024 to sololearn. on 07.11.2024, i got an answer that the issue is fixed.
21st Nov 2024, 7:51 PM
Lothar
Lothar - avatar
+ 2
report to info@sololearn.com. you can update the course by restarting it.
21st Nov 2024, 2:20 PM
Lisa
Lisa - avatar
+ 1
The right way to assign i to the array in the loop would have been..... arr[i] = i; ...and then the output would have been 2
21st Nov 2024, 2:34 PM
Jan
Jan - avatar
0
Jan I know. I didn't make this code, the app gave me that code to find the output.
21st Nov 2024, 2:44 PM
Santi Covato
Santi Covato - avatar
0
Lisa Ok thank you. I will report that.
21st Nov 2024, 2:45 PM
Santi Covato
Santi Covato - avatar