Java OCA OCP Practice Question 431

Question

Fill in the blanks: The ____ operator increases the value of a variable by 1 and returns the new value, while the ____ operator decreases the value of a variable by 1 and returns the original value.

  • A. pre-increment [++v], pre-decrement [--v]
  • B. pre-increment [++v], post-decrement [v--]
  • C. post-increment [v++], pre-decrement [--v]
  • D. post-increment [v++], post-decrement [v--]


B.

Note

Prefix operators modify the variable and evaluate to the new value, while postfix operators modify the variable but return the original value.

Option B is the correct answer.




PreviousNext

Related