Java Coding Question What will be the output of the following code? public class Test { public static void main(String[] args) { int[] arr = {1, 2, 3, 4, 5}; for (int i = 0; i < arr.length; i++) { arr[i] = arr[i] + 1; } for (int num : arr) { System.out.print(num + " "); } } } Options: A) 1 2 3 4 5 B) 2 3 4 5 6 C) 1 3 5 7 9 D) Compile-time error 👉 Comment your answer before running the code. #Java #JavaProgramming #CodingChallenge #RalithonTechnologies #JavaInterview #ProblemSolving #Developers #LinkedInPost
B) 2 3 4 5 6
2 3 4 5 6
B
The correct answer is B) 2 3 4 5 6. Code correctly increments each element by 1.