Er trinkt seinen Kaffee schwarz.
I translated it "He drinks his black coffee", but it was marked as wrong. The correct answer was "He drinks his coffee black." Why is my answer wrong?
The word order is one clue -- just as in English, the "schwarz" should be before the "Kaffee" for "he drinks his black coffee". But the ending on "schwarz" is probably the bigger giveaway: "seinen Kaffee" is in the accusative (since it's the object of the sentence), so "schwarz" would also have to be in the accusative, and you'd get "Er trinkt seinen schwarzen Kaffee". I'm not sure what the correct grammatical analysis of "schwarz" is in "Er trinkt seinen Kaffee schwarz"; personally I think of it as an adverb, because it's telling you how he drinks his coffee, but in any case it's modifying the verb (or the whole sentence), so doesn't take the same case as "Kaffee".
(I'm far from being an expert, so I apologize if it turns out this is wrong, but this is my understanding of it at least!)
In addition to what pont said: just as in English, there is a subtle difference in meaning between the sentences "Er trinkt seinen schwarzen Kaffee" (He drinks his black coffee) and "Er trinkt seinen Kaffee schwarz" (He drinks his coffee black). The first sentence is just a statement of fact telling us what he does, whereas the second sentence is about a preference.
Incidentally, I don't think that "black" in the second sentence is an adverb because it does not refer to the verb ("He drinks blackly") but describes what the coffee, i.e. the object, is like when he drinks it. I think that's called a predicative, which would make sense since adjectives remain unchanged when they are used as predicatives in German (cf. "Das Haus ist schwarz"). But linguistics have never been my strong point. :)