Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

.11 Sprint 1:17 PM 24%10. Done activity-boolean-logic (1) Model 2 Conditional Op

ID: 3742762 • Letter: #

Question

.11 Sprint 1:17 PM 24%10. Done activity-boolean-logic (1) Model 2 Conditional Operator:s Boolean expressions use conditional operators to implement basic logic. If all three operators appear in the same expression, Java will evaluate first, then &&, and finally I If ther e are multiples of the same operator, they are evaluated from left to right. Relational operators are evaluated before && and II, so there is generally no need for parentheses. Operator Meaning &8 and Example Variables int a 3; int b4; int c 5; boolean funny true; boolean weird false Example Expressions a

Explanation / Answer

Answer:7:

a<b &&funny

=(3<4) && funny

=True && True

=True

a<b && b<c

=(3<4) && (4<5)

=True && True

=True

c<a || b<a

=(5<3) || (4<3)

=False || False

=False

Funny && a<c

=True && (3<5)

=True && True

=True

!Funny || weird

=! True || False

=False || False

=False

Answer 8:

(a) The expression ! (a<b) evaluates to false

(b)The expression ! (b>c) evaluates to true

(c) The expression a>b && a>c evaluates to false

(d) The expression a>b || a<c evaluates to True

Answer 9:

(a) As per the condition given

p= !(a<b) and q =!(b>c)

Therefore p && q

=!(a<b) && !(b>c)

(b) The result of the expression

!(a<b) && !(b>c)

= False && True

= False

Answer 10:

Answer 11:

Answer 12:

(a) The modified expression so that && is evaluated before ! is as below

! (a>c && b>c)

(b) the new result is

= ! ( false && false)

= ! false

= true

Answer 13: When the value of p=false then the expression p& q is always false irrespective of the vaue of q. Only when the value of p=true ,then the value of q needs to be looked upon/examined to determine the value of p && q

Answer 14:When the value of p=true then the expression p || q is always true irrespective of the value of q. Only when the value of p=false then the value of q needs to be looked upon/examined to determine the value of p || q

Answer 15:

(a) We should place q to the left of && operator. The reason being q is moe likely to be false as compared to p. If during run time system fids that the value of q=false then the result of the expression will defiitely be false irrespective of the value of p. Hence the system can evaluate the result by examining the value of q alone without proceeding further for majority of he cases. Only when q=true it needs to examine the value of p

(b) p should be placed to the right of the || operator as it is more likely to be true than q. So the system can conclude that the value of the expression will be true when p=true without even examining the value of q. Only when p=false ,system needs to further examine the value of q

Answer 16: JSON supports deserialization of 1/0 as true /false. Jackson serialiser will serialize bolean to 1/0. Without JSON serialiser/deserialiser the expression 1/0 will throw an exception during run time.

p q p &&q p || q ! p false false false false true false true false true true true false false true false true true true true false