First of all the odds that you startle a bear in this way are quite low. There is a good chance that it would have heard or smelled you before you get that close.
That said, if you encounter a bear in the wilderness, your reaction depends on how the bear is acting. In most cases, the bear will be defensive. In this case you should stay calm, talk calmly to the bear, make yourself look big and slowly move away facing the bear, always facing it.
However, if the bear is aggressive, or is approaching you, your reaction should be different. A good guide of what to do in these situations can be found at Parks Canada's website. The page has a lot of good information, but here is the specific part on "if you see a bear":
If you see a bear
Stop and remain calm. Get ready to use your bear spray. Do not run
away.
Is the bear unaware of your presence?
Move away quietly without getting its attention.
Is the bear aware of your presence?
Bears may bluff their way out of an encounter by charging and then
turning away at the last second. Bears may also react defensively by
woofing, growling, snapping their jaws and laying their ears back.
Stay calm. Your
calm behaviour can reassure the bear. Screams or sudden movements may
trigger an attack. Speak to the bear. Talk calmly and firmly. This
lets the bear know you are human and not a prey animal. If a bear
rears on its hind legs and waves its nose about, it is trying to
identify you. Back away slowly. Never run! Running may trigger a
pursuit. Make yourself appear BIG. Pick up small children and stay in
a group. Do not drop your pack. It can provide protection. If you must
proceed, make a wide detour around a bear or wait at a safe distance
for it to move on.
If the bear approaches
Stop and remain calm. Get ready to use your bear spray. Do not run
away. Assess the bear’s behaviour and determine why it is approaching.
Is it defensive?
The bear is feeding, protecting its young and/or surprised by your
presence. It sees you as a threat. The bear will appear stressed or
agitated and may vocalize.
- Try to appear non-threatening.
- Talk in a calm voice.
- When the bear stops advancing, start slowly moving away.
- If it keeps coming closer, stand your ground, keep talking, and use your bear spray.
- If the bear makes contact, fall on the ground and play dead. Lie still and wait for the bear to leave.
Is it non-defensive?
A bear may be curious, after your food, or testing its dominance. In
the rarest case, it might be predatory–seeing you as potential prey.
All of these non-defensive behaviours can appear similar and should
not be confused with defensive behaviours.
The bear will be intent on you with head and ears up.
- Talk in a firm voice. Move out of the bear’s path.
- If it follows you, stop and stand your ground.
- Shout and act aggressively.
- Try to intimidate the bear.
- If it approaches closely, use your bear spray.
Handling an attack
Most encounters with bears end without injury. If a bear actually makes contact, you may increase your chances of survival by following these guidelines. In general, there are 2 kinds of attack:
Defensive
This is the most COMMON type of attack.
- Use your bear spray.
If the bear makes contact with you: PLAY DEAD!
Lie on your stomach with legs apart and position your arms so that
your hands are crossed behind your neck. This position makes you less
vulnerable to being flipped over and protects your face, the back of
your head and neck. Remain still until you are sure the bear has left
the area.
These defensive attacks are generally less than two minutes in
duration. If the attack continues, it may mean it has shifted from
defensive to predatory—FIGHT BACK!
Predatory
The bear is stalking (hunting) you along a trail and then attacks. Or,
the bear attacks you at night. This type of attack is very RARE.
- Try to escape into a building, car or up a tree.
- If you cannot escape, do not play dead.
Use your bear spray and FIGHT BACK.
Intimidate that bear: shout; hit it with a branch or rock, do
whatever it takes to let the bear know you are not easy prey. This
kind of attack is very rare, but it is serious because it usually
means the bear is looking for food and preying on you.