Thomson Reuters interview question

Basic coding questions on OOPS and two programs were given to solve.