Relinquishing command

Minor nitpick (well, maybe it’s a major nitpick): The ship’s captain won’t say, “I’m in command now” when they rush into the bridge or CIC. They’ll say, “I have the conn” (or whatever the current terminology is for that).

As mentioned more than a few times above, the ship’s captain is always in command unless they’re doing something away from the ship for an extended time, such as going on leave. In such cases, the ship’s captain will appoint the ship’s executive officer as Acting Commanding Officer.

In the US Navy, there’s another wrinkle as to who may assume command. Unrestricted Line Officers can command a ship. Other officers can only command units which pertain to their specialty; for example, a Limited Duty Officer with the specialty of Ship’s Clerk cannot command a frigate, but they can command a Personnel Support Activity.

Even if every officer senior to them in rank is killed in an ongoing battle?

The question has pretty much been answered, but here’s my take, as a former qualified submarine Officer of the Deck (OOD). Sorry if I end up repeating some things.

As has been stated, the OP’s hypothetical questions conflate the job of Commanding Officer (CO) with the watch station of OOD. The CO is always in command of a ship even if he or she is asleep or away from the bridge (or Control Room in the case of a submerged submarine). A CO never has to “tell someone they are in charge.” The person in charge is the OOD on watch. (The CO does not stand watch as OOD.) There is always an assigned OOD as part of a rotating watch. On U.S. submarines, watches last six hours.

Commanding officers generally prepare a set of written standing orders for OODs that dictate what they can and cannot do without checking in with the CO. These may be supplemented with watch-specific written orders. For example, a CO may dictate that an OOD may do all the preliminaries necessary for going to periscope depth (PD), but must request permission from the CO before actually doing so (even if the OOD has to wake the CO to do so).

Generally, a CO will be in the Control Room when anything out of the routine is going on. Occasionally, such a situation could continue for days or weeks. (One example that comes to mind is under-ice operations in the Arctic.) In such a situation, the CO may designate another officer as the Command Duty Officer (CDO), typically the Executive Officer (XO), who is the second-in-command on a ship. Generally, the CO will designate in his standing orders what the CDO can authorize, and what still needs to be brought to the CO.

Back to the OOD–the job of OOD actually encompasses two things: being in charge of the ship as a whole, and being in charge of the ship’s movements (referred to as “having the Conn”). Suppose that you have a situation where the OOD is on watch on a submerged submarine, and the CO is also present in the Control Room. If the CO wants something done differently than the way the OOD is doing things, the CO would typically direct the order to the OOD, such as a course change, for example. However, suppose the CO decides that an urgent course change is needed. In such a situation, all the CO has to do is give the order to the helmsman (e.g. "Left Full Rudder!). The helmsman will acknowledge the order, and the OOD will loudly announce: “Captain has the Conn!” to tell everyone in the control room that the CO has taken control of all ship’s movements. This doesn’t mean the OOD can leave–he or she is still the OOD, but they no longer have the Conn until it’s formally tuned back over to them. Only one person can have the Conn at any one time.

During Battle Stations, everyone on board has an assigned watch station. The assigned (usually the most proficient) OOD will take the watch from whomever had it before battle stations was called, and the CO will generally go to the Control Room and take the Conn.

So how does all of this affect the hypothetical situations in the OP?

Hypothetical 1: The CO leaves the bridge (or control room on a submerged submarine), leaving LT Barnes as the OOD. The ship is attacked, so LT Barnes follows the CO’s standing orders. This would include recalling the CO to the Control Room, and manning battle stations. The fastest way to recall the CO would be an all-ship announcement over the 1MC (a type of PA system). LT Barnes would also order the General Alarm sounded, and put the ship into Battle Stations. Once CDR Cooper shows up in the Control Room (assuming he is in the chain of command, and not the Supply Officer, for example), the commander would be treated just like the CO (until and unless the CO showed up), and he could leave the lieutenant as OOD (and give the lieutenant orders), relieve her as OOD, or whatever. The lieutenant would be obligated to defer to him.

Hypothetical 2: This is an impossible situation. While the CO can leave LT Barnes as the OOD, the CO cannot tell LT Barnes to ignore CDR Cooper without relieving CDR Cooper of all his duties (i.e. in effect removing CDR Cooper from the chain of command).

Hypothetical 3: LT Barnes may not legally relinquish command to ENS Dobbs. Should she do so, she will end up getting court-martialed.

Correct. Only an Unrestricted Line Officer can take command of a U.S. Navy seagoing vessel. So if the only surviving officers on a ship are Rear Admiral Adams (a Supply Corps staff officer), Commander Smith (a Medical Corps staff officer), and Ensign Jones (an unrestricted line officer), then ENS Jones takes command. The two staff corps officers don’t have the training or authority to take command of a ship.