As we know any computer program is large. Due to large size, complexity of the computer program increases and it becomes difficult to understand the program. To make a computer program simpler, we divide the program into many small methods and link them by calling one method to the other. Since Java is an object oriented language, we use a class as a wrapper to include all variables and methods inside classes. Classes are also a template for creating objects.
Why you need to create objects? Well, objects provide data structure so that you can use them to build all your logic. Once you have objects then you can then define their relationships.
Let us understand as to what classes (and corresponding objects) you need to create for your computer program. Suppose you have to create a website application for managing inventory in your warehouse. You will need to think about structure of the warehouse, kinds of inventory to be handled, kinds of inventory management to be deployed etc. Typical transactions in a warehouse include facility to receive inventory, moving inventory inside the warehouse (put away transactions), storing inventory in the warehouse, moving inventory outside the warehouse for dispatch (against sales orders or transfer orders) etc.
The master data in a warehouse include warehouse number, bin number, storage type, material number, customer etc. The transaction data may include material quantity, purchase order number, transfer order number, sales order number, date, time etc.
Once you figure out data and entities then you can model your application. The entities will be our classes (which will be objects in runtime) and our data will be contained inside these classes. In our warehouse management system, we can create classes for warehouse, bins, inventory, purchase order, sales order etc. We can then find out relationship between objects which will be interacting with each other in runtime.