Cognizant Interview Question

Introduction 4 codes are based on Java