In Java, what is the primary purpose of defining classes and instantiating their objects?

A) To create reusable code snippets
B) To define the structure and behavior of objects
C) To implement inheritance and polymorphism
D) To optimize memory usage