java - Interview follow up on Class Design by avoiding diamond case -
recently have been asked design question. there 2 classes horse , bird. need design new class called unicorn having methods of class horse , bird.
horse bird | | unicorn
since in java cant extend 2 classes (to avoid diamond problem) how achieve this?
please guide. in advance.
use façade pattern composition achieve this. unicorn class contain instances of both bird , horse , implement relevant methods calling them on these contained instances.
Comments
Post a Comment