Mordenkainen's Tome of Foes introduced the Dybbuk, a neat CR 4 Medium fiend (demon) with a peculiar ability:
Possess Corpse (Recharge 6). The dybbuk disappears into an intact corpse it can see within 5 feet of it. The corpse must be Large or smaller and be that of a beast or a humanoid. The dybbuk is now effectively the possessed creature.
[...]
While possessing the corpse, the dybbuk retains its hit points, alignment, Intelligence, Wisdom, Charisma, telepathy, and immunity to poison damage, exhaustion, and being charmed and frightened. It otherwise uses the possessed target's game statistics, gaining access to its knowledge and proficiencies but not its class features, if any.
[...]
So from that I get that a possessed PC paladin would be able to strike as usual with its sword (same STR and proficiencies), but not use Divine Smite or Lay on Hand, as they are class features.
But what about the spellcasting of, say, a NPC mage? Can the Dybbuk cast spells as if it were the possessed creature?