CompTIA IT Fundamentals FC0-U61 – Question160

A developer is troubleshooting code in an application. The code is supposed to return the word "vegetables" if
the category id is only 2. However, the code is returning vegetables for all values except category id 1. Which of
the following code statements would BEST correct the issue?


A.
If category id = 1 then 'Fruit'
Else 'Vegetables'

B. If category id = 1 then 'Fruit'
Else if category id = 2 then 'Vegetables'
Else 'Candy'

C. If category id <> 1 then 'Vegetables'
Else 'Fruit'

D. If category id = 1 then 'Fruit'
Else if category id >= 2 then 'Vegetables'
Else 'Candy'

Correct Answer: B