Simple Java programs to solve interview questions