So if your behind the wall pipe is 1 1/2" ABS and out of the wall you get female end of a 90 elbow, is the above mentioned slip nut required ? Can't I just cement the horizontal segment in the picture to the elbow end that is getting out of the wall ? Consider the below would be ABS so we have apples to apples :-)
If you have a female end of a fitting sticking out of the wall, you need to buy an ABS male to Desanco fitting. The Desanco fitting should match the pipe size of the existing white drain pipe you have, either 1.5" or 1.25". You can then use the trap piece you have including the nut and washer. This way when you need to take the trap apart to do some repair, you can just remove the nut and remove the trap.
If you are the sort of optimist that uses glue-in traps, and you actually have one of those as opposed to the polypropylene slip-fit trap shown, you can glue it in. You'll need a VERY precise piece of pipe to go from the hub on the wall to the hub on the trap. Get it wrong, and you're going to have to do it over until you get it right.
I much prefer slip-joint traps based on long experience. Glue-in traps tend to involve swearing and sawing sooner or later, slip fit traps don't, because they can be taken apart and adjusted (or taken apart to get the diamond ring out.)
This type will at least let you get the ring out, probably.
This is for the irredeemable optimists.
The slip-fit trap tubing is a much thinner wall and will not fit the glue in hub, and it's a different kind of plastic so the glue won't work on it, either. A 1-1/2" tailpiece from a slip fit trap will slide right in to a 1-1/2" pipe, though I'm also not the sort of optimist who uses 1-1/2" drain pipe, so all mine are adapted up to 2" at the slip joint. But the slip joint adapters themselves are 1-1/2" pipe size. You would glue a suitable pipe into the hub, and a trap adapter to the pipe. There are also compact trap adapters that glue into the hub. Trim the tail of the trap as needed to fit (but don't over-trim it.)