The sentence "The district attorney was upset when Judge Morales dismissed the case."
District attorney and judge only need to be capitalized when it comes before a specific name. Since there is no specific district attorney's mentioned, therefore it doesn't need to be capitalized. However, since the judge's name is Morales, we need to capitalize judge.