Short answer: run defaults delete com.apple.dock persistent-apps; killall Dock in Terminal.
The Dock restarts with Apple's default apps and keeps your size and position. If it comes back empty, use the full reset further down.
Restoring the defaults throws away the apps you pinned. Save them first:
defaults export com.apple.dock ~/Desktop/dock-backup.plist
To go back to your own Dock later:
defaults import com.apple.dock ~/Desktop/dock-backup.plist; killall Dock
The pinned apps live in a list called persistent-apps. When the list is gone, the Dock builds Apple's default set in its place:
defaults delete com.apple.dock persistent-apps; killall Dock
The folders and stacks on the right of the divider are a second list, persistent-others. Delete that one as well if you want those back to the default too:
defaults delete com.apple.dock persistent-others; killall Dock
Your apps stay installed, your files stay where they are, and the Dock keeps its size, position and auto-hide settings.
If the Dock comes back with no apps at all, the lists were rebuilt empty. Run the full reset, which also returns the size and position to default:
defaults delete com.apple.dock; killall Dock
More on what that clears is in how to reset your Mac's Dock to default.
You do not need Terminal to rebuild a Dock one app at a time.
A Dock with gaps or a question mark where an app should be usually means the app moved or was deleted. Drag the app back from Applications. If the Dock reverts to an old layout every time you log in, a configuration profile or a damaged preference file is rewriting it: see why the Dock resets itself.
Once the Dock holds the apps you want, lock the contents so an icon cannot be dragged out by accident:
defaults write com.apple.dock contents-immutable -bool true; killall Dock
Swap true for false before you add or remove an app. Still Dock has the same lock as a switch in the menu bar, and remembers the Dock you had before you locked it.
It depends on your macOS version. Finder, Safari, Messages, Mail, Photos, Calendar, Notes, Music, the App Store and System Settings are always there, and each release adds or drops a few others. The reset command always gives you the set for the macOS you are running.
No. The Dock holds shortcuts. Removing an icon from it never uninstalls the app.
Yes, if you ran the export command first. Run the import command and your pinned apps return.