the Java code for interview questions