As mentioned in l'électeurさん’s answer, the word 果物 needs to be followed by では or something like that in order to mean what you really mean. 「私は果物、いちごやメロンが好きです。」 sounds like a cute imaginary character in a kids’ TV show saying “I am fruit, I like strawberries and melons.”
Those example sentences above would sound more natural in these ways.
(1)「果物では、いちごやメロンとかが好きです。」
(2)「果物だと、いちごとかメロンとかが好きです。」
(3)「果物では、いちごやメロンが好きです。」
(4)「果物だと、いちごとかメロンが好きです。」
Formal vs Casual
では can be formal or casual.
だと is a casual expression, so it’s often used with とか which is also casual.
とか is casual but can be used in friendly keigo.
や can be formal or casual.
Colloquial vs Literary
や can be colloquial or literary.
とか is a colloquial expression.
Using with Nouns or Other Words
や can be used with nouns generally.
とか can be used with nouns, verbs or adjectives.
「イチゴを切るとか潰すとかしてヨーグルトに入れるとおいしい。」
Position
や can be used between nouns.
とか can be used between words or after a word.
Meaning
や and とか have the same meaning.
私は動物園でゾウやキリンを見ました。
私は動物園でゾウとかキリンを見ました。
私は動物園でゾウやキリンとかを見ました。
私は動物園でゾウとかキリンとかを見ました。
All of these sentences above express that the speaker saw elephants and giraffes at the zoo, and imply that s/he also saw other animals.
Conclusion
So, the differences between や and とか are usage and impression.
(3)「果物では、いちごやメロンが好きです。」
is polite or written-language-like. (1)(2)(4) are all casual or friendly keigo style.
(2)「果物だと、いちごとかメロンとかが好きです。」
is the most casual one. とか is very colloquial so can be used in personal emails or something, but can almost never be used in assignment writings, reports etc.