Virtusa interview question

programs on java 1.8 and logical question