What is an object? ● An object in Java is any real-world thing that has properties and actions. ● In other words, an entity that has state and behavior is known as an object. ● Here, state represents properties and behavior represents actions or functionality. What is class? A class is basically user-defined data types that act as a template for creating objects of the identical type. It represents the common properties and actions (functions) of an object. In other words, a class can also be defined as “a class is a group of objects which are common to all objects of one type”. Realtime Example:
Let’s take one interesting example is Mobile
Phone. ● The name of the class is “Phone”. It has different models. But the type is same ‘Phone’. This is the class. ● It has some properties and actions. This is called Object. ● Thus, a phone object is comprised of the properties that the phone has actions that phone does. Ex: ‘Phone Oppo A9 2020’.
Properties are width = 6.5 or “6.5 inch “,
color = “Space Purple”, OS = “Android 9.0”, price = 15000”,brand = “Oppo A9 2020”, and weight = “195 gm”.