Cognizant interview question

Core java, spring framework,basic coding question to test the logic