let me be clear, MN cable(romex) is allowed to be run exposed. However it is frowned upon by electricians and some inspectors will not allow it. It must be supported(staple) with in 8" of a box. Yes you would be with in code to have the cable come out of the drywall of the ceiling and in to a box (boxes have to be supported) nailed say to the top of the cabinet, then to run a cable across the top to another box and then back in to the drywall. But a much better way to do it is to install a box recessed so the the face of the box and its cover will be flush with the ceiling, run a short piece of cable thru a hole drilled in the top plate to your second splice box installed in the back wall, which will also contain the other end of the original cable. install drywall(you have to have drywall behind cabinets) and every thing is inside, and clean looking, the only thing one could see even if they looked above the crown molding is two cover plates.
edit: Just in case it wasn't clear the boxes don't have to be accessible, just the splices contained with in them, so as long as you can take a black cover off and repair the splice your are good.