Q: Do you like to eat ice cream/apples...?
A: No, I don't like [to eat apples]./ Yes, I like [to eat apples].
Is it necessary to include the object in brackets[?]
If you've already repeated a transitive verb from the question, yes.
Ice cream (like pizza) is a substance every human being likes, so that question is needless. (Even those with sensitive teeth or lactose intolerance enjoy eating it; they just don't appreciate the side effects.)
For the question "Do you like apples?" normal answers would have the following formats:
- No. ← A simple negative.
- No, I don't. ← Replacement by a placeholder 'do'.
- No, I don't like them. ← Repetition of the verb and its object.
- No, I hate pomes. ← A negative with a brief explanation.
- No, they're terrible. ← Ditto.
- Not really. I prefer bananas. ← A negative with an alternative.
how about the main verb to eat, can it be omitted as well?
The main verb is like. The infinitive to eat acts like its noun object.
The reason you need to repeat everything (unlike, eg, in Chinese) is because English grammar understands like as the action and the negation I don't like by itself means that the speaker (impossibly) doesn't perform the action of liking at all for anything. S/he hates or is indifferent to everything. You sometimes see people say, e.g., I don't try as a way of disparaging the word or action itself: I don't try. I do everything with my full heart.
Similarly, I like to eat by itself means that the speaker enjoys the action of eating itself, without concern to what specific objects might be involved.