Quiz: Find the Error
Match the errors with these explanations:
a) Strings are objects and should be compared using equals
b) The string friends will never be null
c) Loss of precision may prevent this statement from ever being true even when a person would see that it should be true
d) This statement tries to change the value of the variable instead of comparing it
if (friends = "")
{
return "no friends left";
} |
d | |
if (friends == null)
{
return "no friends left";
} |
b | |
if (friends == "")
{
return "no friends left";
} |
a | |
if (numFriends == numPeople * 0.33)
{
return "friends with 1 in 3 people";
} |
c |