NSIQ Infotech interview question

Difference between lookup and master-detail. Write code for polymorphism