📚 Practice Mode

Java Core Fundamentals - Practice Test 6

Learn at your own pace with hints and detailed explanations

1 / 25
Multiple Choice

public void test(int x)
{
int odd = 1;
if(odd) /* Line 4 */
{
System.out.println(odd);
}
else
{
System.out.println(even);
}
}


Which statement is true?

  1. Compilation fails.
  2. odd will always be the output.
  3. even will always be the output.
  4. odd will be the output for odd values of x, and even for even values.