The effectiveness varies from teacher to teacher; but generally, it works well. (And can be optimized)
The method I describe has a few stages, each dependent on the previous ones.
To teach something you don't know, share this method with the students (after you did a part of it, preferably after reaching the third part). Learn it at a quick pace, and let them see how you learn it.
Two things are achieved in that way: You can answer their questions, and they are exposed to new methods of learning.
If possible, sacrifice a few sleepless nights (not one after the other, mind you) to dive into the material and learn it. Read it, reread it, and then again.
If the night is needed for other things, then allocate time during the day. As I've said, every stage is important.
If you do sacrifice the night, then bear in mind:
There is indication that learnt material doesn't actually "sit well" in the mind if one hasn't "slept on it" (keeping it simple: during sleep, the brain makes new connections in the brain, and that's how we learn).
So after rushing through a subject, you should let that subject cool down.
That last part is the semi-second stage. It usually happens by default, but (speaking from experience here) one might get carried away, so...
After reading the material for a subject, do what your students would do if you had known the subject. Give yourself exercises. At first, find online ones. For APCS-A, I'm pretty sure there are exercises available somewhere on the internet. As is with everything, practice. Start simple with online things, and then:
After you feel sufficiently practiced with the material for a subject, start
creating your own exercises.
This is the big one. This is the main point. This is my answer.
I cannot emphasize that more (I suppose I could make it italic...). This part is, by far, the most important. This is far from saying that one can "skip" to it. I've tried, it doesn't work if you don't do the previous parts.
For a better learning curve, try to think up of a division of a subject (for example, dividing OOP to sub-subjects in a logical). Create exercises for yourself for each division of the subject. Try to make both practical and theoretical questions.
The latter being questions of pure knowledge, and the former - questions of applying said knowledge.
Track the difficulty of the various questions in each sub-subject.
These stages will come in handy when you teach others. You'll have a well ordered collection of exercises, fully covering the material, in varying difficulties.
I have done what I have described on multiple occasions. This works for self learning (Not so surprising
The main point is:
Learn it, as you would let your students learn it
Now, as for answering students' questions:
If you don't know the answer to a student's question, then say so. But also say something like
I'll check and get back to you on that
And then treat the question like one of the theoretical knowledge exercises (mentioned above). Usually, the theoretical knowledge can be found on the spot by searching google. There's no shame to let students see how you find information.
When you get back to the student with the answer, show the student how you found it, detailing how you learnt it. This is both useful for you (to make the knowledge stick in your head), and useful for the student.