operators/flow control Flashcards

1
Q

Will a post-increment produce a different output than the pre-increment in the following for loop?

(for int i = 0; i < 10; ++i) { System.out.println(i): }

A

Nope, it sure won’t.

The flow goes like:

  1. test the condition
  2. if it is false, terminate
  3. if it is true, execute the body
  4. execute the incrementation step
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Does the following compile?

System.out.println(null + null);

A

No.

Only if it were concatenating to a string will null not cause compilation error.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly