You cannot assume interchangeability. You *must* verify the engine codes (often found on a plate on the engine block itself) to ensure compatibility. Even if the displacement is the same, minor differences in components could prevent a direct swap. Things like mounting points, sensors, and wiring harnesses could all be incompatible.
In short: Possibly, but not guaranteed. Check the engine codes first.