The freeway question: you need to look ahead far enough to not have to make a quick stop when leaned over, but if you ARE in such a situation, do you best to reduce lean angle if situation permits. Once bike is upright you can apply maximum braking. If there is no option to straighten the bike up apply both brakes GENTLY.. if you're not leaned way over and road is in good shape, you won't low side. Just make sure the bike is fully straight before you come to full stop. Ideally though, you need to work on looking as far ahead as possible and setting reasonable entry and exit speed to avoid these situations.
You can also practice for it in a lot by going into a turn and then quickly straightening the bike up and applying maximum braking.
personally i'd avoid using both brakes if you are a novice, especially in a panic situation. If you lock both wheels up then the bike WILL fall over. The rear wheel is very easy to lock up, and isn't going to do much anyway.
For a fast stop it's probably better to clutch in (to prevent the bike driving the wheel), and just use the front brake, and then when you are almost at a stop using the rear. As said though try and get the bike upright, so that the tyre isn't trying to do two things at once
The thing to note though is that you should never end up in this situation. You should always try to ride to a speed so that you can stop at any point. If the corner is tight and you can't see around it then don't go hell for leather. Same on the motorway, if you're going around a bend, Then ensure that you are able to stop if you need to.
Another alternative if for example it's wet and you're really in the ****, try and find an escape route. As a bike is narrow you may be able to lane split. This will give you extra time to stop. Be aware however that cars may pull out in front of you, especially if you're going fast. The important thing is not to target fixate on the car in front of you, and look at the gap, as otherwise you will hit the car in front.
One more thing, if you're going around a corner, and it's tighter than you expected, chances are you will make it, just countersteer harder, and look where you want to go. Don't try and brake or straighten the bike up, or you definitely won't make it. Chances are the bike will be fine, it's just you that are having doubts. I was told by the police also not to roll off the throttle, however I do this myself (gently)
The main thing to realise is that unless you want a very short biking career, you have plenty of time to learn these things, take it slow, build up your skill levels, coordination and reflexes. Do some extra training, and try and learn as much as possible.