Cognizant Interview Question

Few basic Java codes