Exprivia interview question

Java patterns