code written for some qs in Java