Answer
(a) Yes
(b) Yes
Work Step by Step
(a) Yes, the heat flow into the system is possible, if the system expands at the same time. An example of such a phenomenon is an isothermal expansion of a gas.
(b) Yes, the heat flow out of the system is possible, if the system compresses at the same time. A relevant example is an isothermal compression of a gas.