A bar exam was a test intended to determine whether a candidate is qualified to practice law in a given jurisdiction. Bar exams were mostly associated with Federation and Lyran Star Empire legal practices. Passage of the bar was required of a law school graduate to become a lawyer, which was then called to the bar.
The bar exam was a pre-requisite for one to graduate from a Lyran university with a Juris Doctor degree. In Lyran legal education parlance, it was a comprehensive examination covering all topics a lawyer was expected to master in order to practice law and was held at the end of the 3L year. Failure of the bar exam meant that the student had to re-take the bar the next semester. (Star Trek: The Stoneship Files: "Tax Crunch")
In the 25th century, the Judge Advocate General office administered its own bar examination, tailored for Starfleet practice. As such, the Starfleet Bar Examination primarily contained essay questions pertaining to the common areas of practice of military lawyers, although Starfleet lawyers ended up practicing in civilian jurisdictions also. (Star Trek: False Vacuum: "Pledge of the Protester")