(covers information from several alternate timelines)
Cadet was a military training rank for students in training to become officers. The rank was somewhat similar to midshipman.
Cadet was a rank which was used at Starfleet Academy to denote students in training to become Starfleet officers. The rank was used in the mid 23rd century throughout the late 24th century. (TOS: "Whom Gods Destroy"; Star Trek V: The Final Frontier; TNG: "The Game")
Becoming a Starfleet cadet was a difficult process and required a significant amount of academic achievement while in high school. Academy entrance standards were particularly high, especially in scientific and math disciplines (such as calculus). Cadets were also expected to maintain a satisfactory grade point average during their attendance at the Academy. Getting bad grades was grounds for a cadet's revocation of appointment from the Academy, also known as "washing out". (TNG: "The First Duty", "Journey's End")
Starfleet cadets were under the same uniform code of justice as Starfleet officers and were in turn subordinate to the orders of superiors. They were also required to report violations of Federation law they observed to their superiors. Cadets were also expected to show military courtesy and respect to senior commanders. In 2370, after Wesley Crusher disrespected Commanders Data and Geordi La Forge and then further disobeyed a direct order from Captain Jean-Luc Picard, it was discussed that Wesley's appointment as a cadet might be revoked. (TNG: "Journey's End"; DS9: "Little Green Men")
In the alternate reality, the final year cadets were hurriedly assigned to supplement the crew of several Federation ships, including the USS Enterprise, upon learning of the attack on Vulcan. A few cadets served as bridge crew on that ship, while stowaway Cadet James Kirk was later promoted to acting first officer when captain Christopher Pike had to leave the ship. He ultimately became acting captain after Spock was proven to be emotionally compromised, and due to his actions in the Battle of Earth, Kirk was commissioned at the rank of captain upon his graduation, alongside the cadets who had served on the Enterprise, some of whom became part of his official crew. (Star Trek)
Starfleet cadets wore uniforms similar to Starfleet officers. Uniforms from the early 2250s consisted of a silvery metallic shirt worn with small starburst crest. By 2256, at least some cadets serving on starships wore standard "Federation blue" Starfleet uniforms of that period, bearing a rectangular badge with the Starfleet delta in the foreground and four horizontal lines in the background. In the 2280s, cadets wore enlisted-style jumpsuits with red-collared undershirts.
The Bajoran Militia had some type of cadet program for those wishing to become militia officers. To become a Bajoran military officer, one first had to become a cadet at the Bajoran Military Academy. (DS9: "Meridian")
|Enlisted personnel||Commissioned officers||Generals and flag officers|
|ENS||LT JG||LT||LT CMDR||CMDR||CAPT||FCAPT||CDORE||RADM||VADM||ADM||FADM|
|2nd LT||1st LT||CAPT||MAJ||LT COL||COL||BRIG||MAJ GEN||LT GEN||GEN||MARSHAL|
|Positions:||Boatswain • Chief • Corpsman • Engineer's mate • Specialist • Technician • Yeoman||TAC • SO • 3rd • 2nd • 1st • CO • DD||Portmaster • Chief of Staff • CinC|
|Services:|| Andorian • Bajoran • Cardassian • Ferengi • Jem'Hadar • Klingon • Romulan • SS • United Earth MACO • United Earth/Federation Starfleet • United States • Vulcan|
Mirror universe: Terran Empire Starfleet • Terran Empire MACO
In Star Trek II: The Wrath of Khan, the Starfleet Academy students were all referred to as "midshipman", however this may be explained by the students in question attending a higher level command track training where they had graduated from cadet status to become midshipmen.
Several non-canon reference books, among them Star Trek: The Next Generation Officer's Manual, attempt to explain the difference between cadet and midshipman as cadet being the standard training rank while midshipman is a rank for advanced command students.