Java OCA OCP Practice Question 1738

Question

Which of the following expressions are valid?.

Select the three correct answers.

  • (a) (-1-)
  • (b) (++ 1)
  • (c) (+-+-+-1)
  • (d) (--1)
  • (e) (1 1)
  • (f) (--1)


(b), (c), and (f)

Note

The unary + and - operators with right-to-left associativity are used in the valid expressions (b), (c), and (f).

Expression (a) tries to use a nonexistent unary - operator with left-to-right associativity, expression (d) tries to use a decrement operator (--) on an expression that does not resolve to a variable, and expression (e) tries to use a nonexistent unary * operator.




PreviousNext

Related