Nokia Interview Question

I was given some coding scenarios and how to write and handle the code.