So, if you want to use a firearm on a bear at close range, a 12-gauge with slug, I hear, is your only good choice.

Choosing a handgun would be an error, & BTW concealing it beforehand would not provide any advantage of surprise versus the bear.

Shooting a black bear as safety measure, however, would be highly dubious strategy. If successful, also very messy.