Question
With x = 0, which of the following are legal lines of Java code for changing the value of x to 1?
 1. x++;
 2. x = x + 1;
 3. x += 1;
 4. x =+ 1;
Answer: Option D
Was this answer helpful ?
Operator ++ increases value of variable by 1. x = x + 1 can also be written in shorthand form as x += 1. Also x =+ 1 will set the value of x to 1.
Was this answer helpful ?
More Questions on This Topic :
Question 2. Which of these statements are incorrect? ....
Question 6. Which of these is not a bitwise operator? ....
Question 8. Which of these is returned by greater than, ....
Question 10. Which of these statement is correct? ....
Submit Solution