Cognizant Interview Question

OOPS concept and gave code to solve