The sketch will indeed run, sending on the serial lines when it is repowered or reset.
After upload, the TxData LED starts flashing, indicating that serial transmit is happening.
If you don’t open a Serial Monitor or a terminal program, or any program that takes data from the serial port, the TxD LED will eventually stop flashing. What happened? Well, nothing was taking the data over the USB port, The TxD LED is controlled by the USB<–>Serial chip, and once the serial buffer is full, the LED comes on and stays on.
If uou unplug and replug the Arduino, the TxD LED will not come on. This does not mean that the AVR on the board is not transmitting; only that the LED is not being turned on by the USB<–>serial adapter, because there is nothing on the PC connecting to the USB the Arduino is on.
Were you to connect the TxD line to the RxD line of another Arduino, you would see that it’s still transmitting.
Here’s a little experiment to help convince you that it works.
Attach a resistor (I used 100 ohms) and an LED in series between TxD (pin 1) and +5V. Plug tyou Arduino in. You’ll see that even though the board’s TxD LED does not flash, the LED you attached does flash, because it IS sending data.
Now change your sketch to send a longer string, say 50 characters or so, and make the delay() 500. Open the Serial Monitor, and observe the LEDs. They will both flash in uison, and the string will appear on the Serial Monitor. Exit the monitor and let the Arduino keep running. Soon, the Arduino’s LED will stay on, indicatind a full buffer, but the LED you attached will keep flashing. Why? Because the Serial Monitor WAS attached, and communicated with the Arduino, and when you detached Serial Monitor, the Arduino stopped having its Serial Buffer emptied.
Remember, USB is NOT the same as Serial. it requires handshaking to take data out of the buffer.