Been going hiking all my life and never needed a gun not even once.
The only times I would carry a firearm out was when I was hunting and then was a rifle.
If I really thought there was real danger of being attacked by a bear, wolves or Mountain Lions I would take a medium or large bore rifle like a .375 Winchester, .45-70, .450 Marlin or .444 Marlin, or even a Short Barreled .12 Gauge loaded with slugs. Above all I wouldn't go out alone, always take someone with you in dangerous areas.
If people think their 9mm, .40 S&W or .45 ACP are are going to stop a Bear, like a Grizzly from attacking you then I really wish you luck because all you will end up doing is making it mad,
none of them have enough power to get through the fat layer and reach the vitals.
IF you do plan on going out in those areas speak with the park rangers before going out and listen to what they have to say.