I had the same problem - this is how I solved it.
I have an iMac 21.5 inch 2.9GHz that was running Mavericks 10.9.1 that I purchased on January 20th 2014. In December the screen started going crazy, it was stretched out and flickering, so much so, that I couldn't even restart it as the dock was down under the edge of the display. So I took it to the Genius bar at Apple and they repaired it by replacing the display (took a couple of days only - very professional and happy with their work).
Everything worked fine again, except my external monitor no longer worked. That is, the iMac recognised the external monitor (I could see its features in the System info > Hardware > displays) but the screen was black. It was an LG monitor attached via a VGA cable with a Thunderbolt adapter. Note: It worked fine before I took the iMac to Apple, but after they had replaced the display I lost my external monitor.
As I still had an Applecare account I called them > waited 15 minutes until I could talk to someone. We did the following steps:
1) SMC restart
2) PRAM restart
3) Restart in Recovery mode (used Disk Utility to check the MJac HD - all was normal)
4) Restart in Safe mode
5) Upgraded to OSX 10.9.5 Mavericks
Nothing worked!
So to fix this issue I bought a third party cable (a Belkin HDMI to Mini DisplayPort (Thunderbolt) adaptor. As soon as I plugged in this new cable the external monitor came to life! Note: there are also VGA to Thunderbolt cables available but since my external monitor had HDMI ports I decided to try this.
Seems to me (at least in my case) that it's a hardware problem, not a software issue.
Note: I didn't want to upgrade to Yosemite as I was concerned about losing my Bootcamp partition, which I have spent months installing software that I didn't want to lose. Apparently, there is a risk the Yosemite can wipe the bootcamp partition so I stopped at 10.9.5 (Mavericks).
Hope this helps ; )