🎴 Flashcard Mode

Java Core Fundamentals - Practice Test 6

Card1 / 25
Mastered0
Review0
QuestionClick to flip

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?

AnswerClick to flip back
A
Compilation fails.
💡 Explanation:

The compiler will complain because of incompatible types (line 4), the if expects a boolean but it gets an integer.

Change Mode