"Vegetable" is defined by how a plant is cooked and eaten, and so has a lot of cultural and context specific influences. A vegetable can be a root (potato), a stalk (celery), a fruit (cucumber), seeds (beans), even non-plant fungi (mushroom).
A fruit has a very specific definition (especially in a biological or botanical usage). It's the "seed-bearing structure in flowering plants that is formed from the ovary after flowering" (Wikipedia).
The part of the cucumber we eat is the fruit (you can see its seeds). But the way we prepare and eat it means we classify it as a vegetable.
> The question of whether the tomato is a fruit or a vegetable found its way into the United States Supreme Court in 1893. The court ruled unanimously in Nix v. Hedden that a tomato is correctly identified as, and thus taxed as, a vegetable, for the purposes of the Tariff of 1883 on imported produce. The court did acknowledge, however, that, botanically speaking, a tomato is a fruit.