Virtusa Interview Question

programs on java 1.8 and logical question