Neptune Ubicom interview question

java oops implementation question from hacker rank