Cognizant interview question

Basics to tricky questions in java