You have to learn by heart. (And you can look it up in the dictionary.) But:
- All plurals are 'de' words.
- All diminutives are 'het' words, except for the plural ones, which are 'de' words.
There are a few 'rules' but there are so many exceptions... But, when in doubt, use 'de'. About 75% of the nouns are 'de-woorden'. ;)
Je en jij is in principle the same, and are both correct in the sentence showed in Duolingo. However, 'jij' is a slightly more 'emphasized' version. For example the sentence 'jij hebt de melk' would rather be used in a situation like: person 1: Wil je me de melk geven? person 2: Jij hebt de melk daar bij je staan.
Or an example with opening the door: Person 1: Wil je de deur openen? person 2: Jij hebt de sleutels.
Here 'je' would be incorrect. So 'je' is used to point out in a neutral way that the other person has the milk/keys/whatever. 'Jij' is used to really point out that the other person has the milk/keys/etc.
In the sentence shown in Duoling both 'je' and 'jij' are correct. In real conversation it depends on the situation which is used.