Booleans Flashcards
equal to
==
not equal to
!=
what do booleans do
compare two things
what will booleans be assigned
true or false
booleans are used with
if statements
how to invert a boolean
!
if a is true and b is false what will a&&b give
false (a and b)
if a is true and b is true what will a&&b give
true (a and b )
what sign is used for and
&&
what sign is used for or
||
if a is true and b is false what will a||b give
true
if a is rue and b is true whta will a||b give
true
if a is false and b is false what will a||b give
false
if a is true what will !a give
false
boolean ! associativity (which direction is it read in)
right to left
boolean && associativity
left to right
boolean || associativity
left to right
what is the precedence of the three (!, || and &&)
- !
- &&
- ||
where do the boolean operators fir into the overall precedene
between equality and conditional
what order will the following operations occur in?
boolean cannotDrive = (age>17) || (!hasLicence) ;
- <
- !
- ||
- =
what order will the following operations occur
boolean canDrive = (age>17) && (hasFullLicence || hasProvisionalLicence);
- >
- ||
- &&
- =
Brackets override precedence
what would be the precedence here?
boolean canDrive = (age>17) && hasFullLicence || hasProvisionalLicence;
is that what we want?
- >
- &&
- ||
- =
No