DXC Technology interview question

basic java question along with oops and code snippets