CEDCOSS Interview Question

Write a program in java for the given pattern