Problem statement: For given UML diagram we have to write Classes. This type of question is asked in technical interview to test the basic understanding of UML.
![](https://interviewsansar.com/wp-content/uploads/2023/01/is-uml-animal-q1.jpg)
In below UML Diagram, Animal class has been extended/Derived from the Tiger base class.
Answer: Given UML diagram is wrong as it does not follow the “IS-A” relationship in inheritance.
![](https://interviewsansar.com/wp-content/uploads/2023/01/is-uml-animal-qa1.jpg)
Above UML states that “Animal IS-A Tiger” which is wrong. Correct form is
“Tiger IS-A Animal”, Hence, Tiger class should be derived from Animal class not Animal from a Tiger.
This is the correct UML Diagram.
Note: Interviewer expectation is to just correct the UML, Not to write a class.
NOTES
![](https://interviewsansar.com/wp-content/uploads/2023/01/is-uml-animal-qa2-a.jpg)
Further examples “Cat IS-A Animal”, “Dog IS-A Animal” and “Camel IS-A Animal”, so, all Cat, Dog, Tiger and Camel should be derived from Animal class.