"in time" means there is an event that occurs at a specific time. If the time passes, it is too late. In time has the sense of "before the time comes." "Before it is too late" has the same meaning as "in time".
"Will the letter make it in time for the deadline""
"I've got to hurry if I want to make get to the train in time to board."
"I don't know if I can finish my term paper in time."
"The test was so long that I couldn't finish it in time."
"on time" means that there is a scheduled time for something to occur. If it happens at the scheduled time, it is "on time." "On time" is used with work, appointments, etc. "On time" has the sense of exactly at the proper time, not before, and not after.
"Please arrive on time."
"Are the trains on time today? I hate it when they are running late."
"I'm always on time to work."
"That clock is on time."
Actually, jut in case it causes confusion to anyone, I would like to point out that "she will understand how to cook in time" is ambiguous. It could mean she will know how to cook in time for the exam or some other event. Or it could mean that she will be able to cook eventually.
Just to be clear: "in time" can have three meanings:
1. "early enough":
I hope he will get there in time for the exam.
Do you think we'll be home in time for dinner?
2. "in the future; eventually":
In time he'll understand what happened between his parents.
Don't worry, she'll learn how to cook in time.
3. "in the correct rhythm or tempo":
Look, the monkey is playing the drum in time with the music.