Most divorces will be resolved by the parties and finalized by the court before you ever get to a formal court hearing. Go here for an overview of the entire process.
But if you get this far and still can't agree on certain issues, you may need a formal court hearing. After hearing evidence, a Judge will make final decisions on your unresolved issues. In some cases, a court Magistrate may hold a similar type of hearing to determine child support issues. More details here.
This set of short videos will help you better understand something about the court hearing process and how to prepare.
Go here to learn about the entire divorce process in Maine (text and video).