Page 345 - Computer_Science_F5
P. 345
Computer Science Output:
FOR ONLINE READING ONLY
Figure 5.11: Bit operations
(ii) 7 = 0111
7>>2= 1 in binary ; 7>>2=1 in Decimal
(iii) 60= 111100
60>>2 = 001111 in Binary; 60>>2 = 15 in Decimal
(d) Logical operators
This include logical AND : &&, logical OR : || and logical NOT : ~ !. Figure 5.12
and Table 5.11 shows the logical operators supported by Java.
AND OR NOT
Figure 5.12: Logical operators
Table 5.11: Logical operators
Operator Type Symbol Description Syntax example
Logical AND && The condition becomes true A&&B
when both the operands are
non-zero
Logical OR || The condition becomes true A||B
when any of the two operands
are nonzero
336
for Advanced Secondary Schools
Computer Science Form 5.indd 336 23/07/2024 12:34

