When the pin is set to input, if you want to ensure it is at high or low you can set what is called a "weak pullup" or "weak pulldown" if the microcontroller has this available. This looks like a high resistor connected between Vdd (or ground) and the pin, which pulls it high or low weakly, so something can drive it to another state easily without using too much current (an output connected to an output is a bad idea, and called "bus contention" since the two outputs fight to set the line to their particular state. The line will generally end up in between states, where exactly depends on the relative strength of each driver)