Java exercises from class