A is used with a word beginning with a consonant sound. For instance, "a dog" and "a university" (university is pronounced with the sound "yu" at the beginning). Words which begin with a vowel sound use "an" instead, for instance "an apple".
Typically, you use "the" when referring to something already mentioned or when speaking about something specific/unique. For instance, you can suddenly yell, "Look! The three boys over there are writing graffiti on the wall." without having even mentioned the boys or the wall yet. Screaming and directing the listener's eye to the scene is also counted as "mentioning something earlier" since it sets up a context and makes it clear what you are referring to.