Java practice for exam