69.9k views
0 votes
Assume that x and y are int variables with x = 5, y = 3, and a and d are char variables with a = 'a' and d = 'A', and examine the following conditions:Condition 1: (x < y && x > 0)Condition 2: (a != d || x != 5)Condition 3: !(true && false)Condition 4: (x > y || a == 'A' || d != 'A')

a)All 4 Conditions are true
b)Only Condition 2 is true
c)Condition 2 and Condition 4 are true only
d)Conditions 2, 3 and 4 are all true, Condition 1 is not
e)All 4 Conditions are false

User Lgants
by
7.3k points

1 Answer

6 votes

Answer:

d)Conditions 2, 3 and 4 are all true, Condition 1 is not

Step-by-step explanation:

Condition 1: (x < y && x > 0)

This will evaluate to False because 5<3 = false. X>0 = true.

False && True = False

Condition 2: (a != d || x != 5)

This will evaluate to True because a != d is True. X != 5 is False.

True || False = True

Condition 3: !(true && false)

This will evaluate to True because !(False) = True

Condition 4: (x > y || a == 'A' || d != 'A')

This will evaluate to True

X>Y = True

a=='A' is False

d != 'A' False

True || False || False = True

From the above, the correct answer is:

d)Conditions 2, 3 and 4 are all true, Condition 1 is not

User Cao Lei
by
7.3k points