I'm no expert on this, but I know the arrangements varied by era and size and type of ship. The big 1930s liners had very substantial telephone systems with big manual switchboards - presumably it wasn't worth installing Strowger automated exchanges given the pattern of use. Only the first class cabins had phones actually in the rooms. The ships also had facilities to allow passengers to make ship to shore phone calls.
Plenty of technical info on the Queen Mary here:
http://www.sterling.rmplc.co.uk/visions/decks.html