# State diagram of DFA

I'm trying to understand how to create state diagram of DFA. I found following example. On the first diagram I dont understand why we need fourth state when third state is final and there is no transitive function from fourth state to another state. And one more question about second diagram. Can't this automata take the word aaaa?

• The fourth state is a junk state. You need one to take the control of the forbidden words. BtW there is a typo in the exercise, i think, the language must be $\{w | w$ has exactly two a's$\}$. For the second one, no. It stays in the first node, because of the definition of the language, you need two b's. – Phicar Nov 1 '14 at 15:58

The situation is further confused because the answer you are given for the left-hand automaton is wrong. The automaton pictured there accepts strings with exactly two as, not strings with exactly three as. I will suppose that the question was misprinted, and should say $$\{w \mid \text{w has exactly \bf{two} \mathtt{a}'s}\}.$$
Yes, the second DFA cannot take a word $aaaa$ as it is the language of words with at least two b's with no restriction on the number of $a$'s. Moreover, the first graph is wrong it accepts the language of exactly two $a$'s.