Multiple choice java

Which one of the following syntactic constructs is not a simple expression?

  1. null

  2. 43

  3. x 2

  4. print()

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

It's a compound expression consisting of simple expression x (variable name), the addition operator ( ), and simple expression 2 (a 32-bit integer literal).

AI explanation

'x 2' — two tokens with no operator between them — is not valid, well-formed syntax at all in typical expression grammars (it's a syntax error, not a legal simple expression), which is why it's the odd one out. 'null', '43', and 'print()' are all syntactically valid simple expressions: a literal, a numeric literal, and a function call expression, respectively, each evaluating to a single value under normal language grammars.