It depends on the location of a noun in the sentence. In the sentence, "I eat the apple," the apple is the direct object of the sentence. As the subject of the sentence, nominative case, the apple is just "der Apfel." In the accusative case, "der Apfel" turns into "den Apfel" because it is the direct object of the sentence. Dative case is used when the noun in question is the indirect object, when it becomes "dem Apfel". Genitive is a case that might use a possessive. For example, in English a person might say "my brother's apple", which could also be "the apple of my brother's". In German this would become, "der Apfel meines Bruders"; note that the ending for "mein" changes on the basis of Bruder, not apple, because it is Bruder that is in the genitive case here.