This confusion is because of the different uses of the words in different contexts.
In cooking (and come to that in eating), rhubarb is usually regarded as a fruit, and marrows, runner beans and maize are vegetables. Apples and strawberries are "obviously" fruits. Generally, dessert or sweet things are culinary fruits, and main-course or savoury ones are vegetables.
Scarlett has explained the botanical meaning of fruit very well -- so botanically beans, peas, okra, marrows etc are definitely fruit. Rhubarb is of course just a leaf-stalk.
Apples and pears are technically "pomes", or false-fruits -- the main part is a swollen stem surrounding the true fruit (which is just the bit round the seeds). Plums, on the other hand, are true fruit.
Individual maize ("corn") seeds are fruits, but the cob is not part of the fruit proper. A strawberry is equivalent to the cob part of maize, and so in this sense is not a fruit but mainly a swollen receptacle -- the fruits are just the little seeds dotted over the surface.
However, the discarded shells of nuts etc are usually part of the fruit.