DeviceDriven interview question

Solve a Java program