I have lots of experience with black bears, as a summer job I have taken children 8 and up on hiking and canoe trips in black bear territory. In a bear encounter it is a simple matter of making lots of noise to chase it away.
With one particular group of 14 yr olds we had 2 separate nights in one week where a bear wandered by our campsite in the evening, with the second bear the kids were complaining because they had to stay up and make noise instead of going to bed. That is how not scared they were.
This works fine because it is an isolated area where few people go and those who do know better than to
feed them. These bears live on a diet of wild berries and occasionally scavenge kills from a real predator. I have never brought a gun, bear mace, or bear bangers. I just sing to them, my singing will chase anything away.
If you do live in an area where people feed the bears, or allow them to scavenge livestock, they can become predatory. If you have neighbors who allow them to scavenge garbage and dead livestock, then you need to be very careful with them.
As a kid a some of my neighbors decided to raise wild boar as livestock, it was a terrible choice, they are aggressive, escape artists. So now there are wild pigs running around and reproducing faster than they can be hunted down. They are in the 300-600 pound range. These animals are sometimes called the poor mans grizzly because when injured they will attack a hunter instead of trying to run away.
Domestic pigs would be much less aggressive but they can probably protect themselves almost as well. I would expect an encounter between a pig and a black bear to end with the bear running for it's life.