Answer:
Output will be -1 .As we know that IndexOf method returns 0 if it finds the suitable match or particular value otherwise returns -1.And here List collections have 2 items i.e. 1 and 2.But 5 is not there in List.So IndexOf will search 5 inside List.Therefore it will return -1 because it will not find 5 inside List.
Asked In: Many Interviews |
Alert Moderator