What is the primary purpose of handling exceptions in Java programming?
A) To terminate the program if an error occurs.
B) To manage and respond to runtime errors in a controlled manner without crashing the program.
C) To prevent all types of errors from occurring in the program.
D) To automatically fix errors in the code.