German U Boats carried two types of deck guns, the 8.8cm (on Type VII) and the 10.5cm (on Type IX) I, VII, XI and X all were armed with guns, and they were served by a crew of 3 men, under a watch officer, and it was a tough job to get the ammo up to them as a chain of additional crew had to pass the shells up from the ammuntion storage down below, with few ready rounds being stored on a deck locker....
there was no advanced sighting other than what came with the gun and experience but a trained crew could fire maybe 15 rounds a minutes and with good accuracy, relatively. Due to potential targets being armed themselves more and more as the war went along, use of deck gun was less and less....
there were pre war plans to create an XI U Boat Cruiser with four gun mounts in 2 turrets but they were never built.

These boats would have carried a Ar 231 aircraft as well, three were contracted but as far as records show, none were laid down and all were cancelled.
info here:
http://www.uboat.net/technical/guns.htm
http://www.uboataces.com/tactics-deckgun.shtml
http://www.uboataces.com/weapon-deck-gun.shtml