It depends on the context since different words mean different things in different contexts.
In botany, fruit refers the part of a flowering plant that has seeds. Things like apples and pears are botanical fruits, but so are tomatoes, cucumbers, legumes, and eggplant. The thing that makes them all fruit is they come from flowering plants and are contain seeds from that plant.
Vegetable is not a botanical term.
In cooking, fruit usually refers to any part of a plant that tastes sweet and is often eaten uncooked. A vegetable is usually any part of a plant that is savory and is often eaten cooked.
There are some legal classifications for foods too that may be different than the above definitions. For example, imported vegetables might be taxed differently from imported fruits and the law would just have to have a list of what counts as a fruit and what counts as a vegetable. Or it might matter for meeting nutritional guidelines.
So tomato is a fruit botanically speaking, but a vegetable in terms of cooking. On the other hand, jicama is not a botanical fruit, but it is a culinary fruit.