Java OCA OCP Practice Question 809

Question

Fill in the blanks:

Given a variable x, ___ decreases the value of x by 1 and returns the original value,

while ___ increases the value of x by 1 and returns the new value.

  • A. x--, ++x
  • B. x--, x++
  • C. --x, x++
  • D. --x, ++x


A.

Note

Prefix operators, such as --x and ++x, modify the variable and evaluate to the new value, while postfix operators, such as x-- and x++, modify the variable but return the original value. Therefore, Option A is the correct answer.




PreviousNext

Related