Question 135 / 297:  What is the result of compiling and running the following code?
public class Tester {

public static void main(String[] args) {

int x = 0;

int i = 1;

for (; i > 0; i--)

if ((++x > 0) | (--i > 0))

x++;

System.out.println(x + "" + i);

}

}

A  Compilation error
B  21
C  20
D  2-1
<< First < Previous Next > Last >>
Explanation:

Notice that we are using a non-short-circuit operator |, which means that the second operand will be evaluated no matter what the result of the first operand

Exam Home Page
Ask
Prateek Ashtikar
Start Quiz
Tess Armstrong
Start Quiz
Copy and paste the following HTML code into your website or blog.
<iframe src="https://www.jobilize.com/embed/java-certification-questions" width="600" height="600" frameborder="0" marginwidth="0" marginheight="0" scrolling="yes" style="border:1px solid #CCC; border-width:1px 1px 0; margin-bottom:5px" allowfullscreen webkitallowfullscreen mozallowfullscreen> </iframe>