What is the final value of a after the loops are executed in the following…
PYQ IBPS SO CRP SPL-XII (2022)
What is the final value of a after the loops are executed in the following program?
public class Main {
public static void main(String[] args) {
int a = 0;
for (int i = 0; i < 5; i++) {
a++;
}
for (int j = 0; j < 5; j++) {
a--;
}
System.out.println("Final value of a: " + a);
}
}- A.
-5
- B.
0
- C.
5
- D.
10
- E.
None of the above
Attempted by 26 students.
Sign up free to check your answer
Sign up freeLoading lesson…

