Cognizant interview question

random question on Java and SQL queries