Which symbol represents the increment operator in Java?
a) ++
b) --
c) +=
d) *=
What does the post-increment operator (i++) return in Java?
a) Increments the value and returns the incremented value
b) Returns the current value and then increments it
c) Doubles the value of the variable
d) Decreases the value by 1
What is the result of the expression: int x = 5; int y = x++; in Java?
a) x = 6, y = 6
b) x = 5, y = 6
c) x = 6, y = 5
d) Compilation error
Which of the following is the pre-increment operator in Java?
a) ++
b) --
c) +=
d) *=
What is the result of the expression: int a = 8; int b = ++a; in Java?
a) a = 8, b = 8
b) a = 8, b = 9
c) a = 9, b = 8
d) a = 9, b = 9
Which operator is used to increment the value of a variable by a specific number in Java?
a) ++
b) --
c) +=
d) *=
What is the value of 'num' after executing the code: int num = 10; num += 5; in Java?
a) num = 10
b) num = 15
c) num = 5
d) num = 20
Which of the following statements is true about the increment operator in Java?
a) It can be used with boolean variables.
b) It can only be used with integer variables.
c) It returns the current value and then increments the variable.
d) It decreases the value by 2.
What does the expression: int x = 3; x += x++; evaluate to in Java?
a) x = 4
b) x = 6
c) x = 3
d) Compilation error
Which operator increments the value of a variable by 1 in Java?
a) ++
b) --
c) +=
d) *=
Answers:
a) ++
b) Returns the current value and then increments it
b) x = 5, y = 6
a) ++
d) a = 9, b = 9
c) +=
b) num = 15
b) It can only be used with integer variables.
c) x = 3
a) ++
No comments:
Post a Comment