Depends on the dog.
We had* one puppy that definitely knew where it was supposed to crap, but if I put him outside for an hour while I got ready to leave the house, the first thing he did when I let him back in was crap right in front of me... he'd then bolt because he knew there'd be trouble.
I have no understanding of why he did this, but do it he did.
*This is the only dog my family ever gave away because we couldn't handle it.