UC Merced Interview Question

how to handle the classes