Which of the following is the assignment operator in Java?
A
= B
== C
-> D
:
Analysis & Theory
The `=` operator assigns a value to a variable.
What is the result of the expression: `5 + 2 * 3`?
A
21 B
11 C
15 D
10
Analysis & Theory
Multiplication has higher precedence: `2*3 = 6`, then `5+6 = 11`.
Which operator is used to compare two values in Java?
A
= B
== C
!= D
<>
Analysis & Theory
`==` compares values. `=` is used for assignment.
Which operator is used for logical AND in Java?
A
& B
&& C
| D
||
Analysis & Theory
`&&` is used for logical AND. `&` is bitwise AND.
What will be the value of `x` after: `int x = 5; x += 3;`?
A
5 B
3 C
8 D
15
Analysis & Theory
`x += 3` is shorthand for `x = x + 3`. So, `x = 8`.
Which of these is a ternary operator in Java?
A
?: B
?? C
:: D
===
Analysis & Theory
`?:` is the ternary conditional operator: `condition ? true : false`.
What does the `++` operator do?
A
Adds two values B
Increments value by 1 C
Checks equality D
Assigns a value
Analysis & Theory
`++` increases a numeric variable by 1.
Which operator is used to find the remainder in Java?
A
/ B
% C
// D
\
Analysis & Theory
`%` returns the remainder of a division.
Which of the following is a bitwise OR operator?
A
|| B
| C
& D
^
Analysis & Theory
`|` is bitwise OR. `||` is logical OR.
What is the output of: `System.out.println(10 > 5 && 3 < 1);`?
A
true B
false C
error D
null
Analysis & Theory
`10 > 5` is `true`, `3 < 1` is `false`, so `true && false` is `false`.