The Enterprise-E crew find B-4 in pieces on a pre-warp planet and take him back to the ship to be assembled. They decide to transfer Data's memory to B-4, blissfully forgetting the disasters they faced dealing with Lore.
B-4 reveals himself to be part of Shinzon's master plan and tries to break into the Enterprise's computers. He is caught, and Data takes his place in order to get on board the Scimitar and rescue Picard.
At the end of the film, following Data's destruction aboard the exploding Scimitar, there are hints that Data's programming still flows in B-4's circuitry, and that -- like Spock -- Data may return from oblivion.
B-4's physical and mental abilities are presumably similar to those of Data.