3i Infotech interview question

oops concepts and some sql quires