die Kostprobe
sample
A small amount of a food or drink that you try in order to test the taste.
Auf dem Markt gab es kostenlose Kostproben von verschiedenen Käsesorten.
At the market, there were free samples of different kinds of cheese.

sample
Loading your saved state.
sample
A small amount of a food or drink that you try in order to test the taste.
Auf dem Markt gab es kostenlose Kostproben von verschiedenen Käsesorten.
At the market, there were free samples of different kinds of cheese.

The word is made up of 'Kost' (a formal word for food/nourishment) and 'Probe' (test/sample). So a 'Kostprobe' is literally a 'food test.'
Nehmen Sie doch eine Kostprobe von unserem neuen Olivenöl.
Please take a sample of our new olive oil.
The context makes clear which meaning is intended. If it is about food or drink, it means a small tasting portion. If it is about art, music, or abilities, it means a short, representative impression.
Hier ist eine Kostprobe vom Hochzeitskuchen.
Here is a sample of the wedding cake.
In connection with food, 'Kostprobe' (sample) is often used with the preposition 'von' (of/from). Typical verbs are 'anbieten' (to offer), 'bekommen' (to get), or 'nehmen' (to take).
Auf dem Weinfest habe ich viele kostenlose Kostproben bekommen.
At the wine festival, I got many free samples.
In this figurative meaning, a person's skill or work is often demonstrated. For example, you give 'eine Kostprobe seines Könnens' (a sample of his skill) or 'eine Kostprobe ihrer Schreibkunst' (a sample of her writing skill).
Der Autor las als Kostprobe das erste Kapitel seines Romans vor.
As a sample, the author read the first chapter of his novel aloud.
example
'das Beispiel' and 'die Kostprobe' can both give a first impression of something. A 'Beispiel' generally shows what something is like or how something works. A 'Kostprobe' is only a small part or short excerpt of something. The word also comes from trying food, but it is also used for music, texts, or demonstrations. You can confuse the words because both can help make something larger understandable. 'Beispiel' fits better for explaining; 'Kostprobe' fits better when you briefly show something or let someone experience it.

Am Abend gibt Lea eine kurze Kostprobe aus ihrem neuen Lied.
In the evening, Lea gives a short sample from her new song.
Vor dem Termin hat Ben ein Beispiel für seine Idee vorbereitet.
Before the appointment, Ben prepared an example of his idea.