Digital pianos do not have the same warm and resonant sound that acoustic pianos have because they do not have strings and hammers. However, technology has improved significantly over the years and many digital pianos can come very close to replicating the sound of an acoustic piano, using high-quality recorded samples and sophisticated sound processing. The best digital pianos can provide a sound that is almost indistinguishable from a well-maintained acoustic piano to an untrained ear.
But the sound is just one part of the equation; the tactile feel of the keys is another important factor. Here too, some high-end digital pianos have managed to closely emulate the feel of an acoustic piano, with hammer action keys and various other features that make the keys respond and feel like real piano keys.
So, to summarize, whether a digital piano sounds like a real piano is subjective and depends on the specific models