What is the output for y?

```
int y = 0;
for (int i = 0; i < 10; ++i) {
y += i;
}
System.out.println(y);
```
a. 10
b. 11
c. 12
d. 13
e. 45

e. 45
The loop is executed 10 times for i from 0 to 9. Each time, i is added to y. So y = 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9, which 45. The correct answer is E.

Computer Science & Information Technology

You might also like to view...

A macro enables you to automate repetitive tasks by ________ the steps that you have taken to accomplish them

Fill in the blank(s) with correct word

Computer Science & Information Technology

An antivirus application has found a file that states the file is part of a virus, but it cannot be deleted by the application. What should you do?

A) Manually delete the file. B) Repartition the hard drive. C) Reload the operating system. D) Use a better antivirus application.

Computer Science & Information Technology