Encounter at Farpoint (1) - S1-E1
McCoy: How old do you think I am anyway?
Data: 137 years, Admiral, according to Starfleet records.
McCoy: Explain how you remember that so exactly.
Data: I remember every fact I'm exposed to.
McCoy [looking at Data's ears.]: I don't see no points on your ears, boy, but you sound like a Vulcan.
Data: No, sir. I'm an android.
McCoy: Hmm...almost as bad.
Answer: Yes. The doors to the holodecks can be locked when in use by anyone aboard the Enterprise so they couldn't be disturbed. However, high ranking officers like Captain Picard could override the doors as it's seen that overrides are in use even for the crews quarters. Even Barclay, when he's indulging in one of his fantasies could have the doors to the holodeck unlocked by an override code.