Foxconn, the worlds largest contract electronics maker, has posted a 14% rise in quarterly profits as it rides a wave of demand for AI. The increase was better than predicted.