Cognizant interview question

OOPS concept and gave code to solve