IBM Interview Question

Two java programs are given in Hackerrank test