‫Java is an object oriented programming language.
‫The core concept of the object oriented approach is to break complex problems into smaller objects.
‫An object is any entity that has a state and behavior.
‫For example, a bicycle is an object.
‫It has states like first gear model year and so on.
‫Behaviors like braking accelerating and etcetera.
‫Now, before we create any object, we need to define the class.
‫A class is a blueprint for the object.
‫We can think of a class as a sketch or prototype, for example, of a house.
‫It contains all details about the floors, doors, windows and etcetera.
‫Based on these descriptions, we build the house.
‫Since many houses can be made from the same description, from the same blueprint, from the same prototype,
‫we can create many objects from a class.
‫Now let's learn how to create a class in Java and see it in action outside the scope of the the class.
‫My class.
‫You can see that we were working with classes before because my class is a class and the main method
‫is one of the methods inside my class.
‫Class outside the scope.
‫Here I'll create a class starting with a class keyword so we can create a class in Java using the class
‫keyword followed by the name of the class.
‫This is the syntax of creating the class.
‫We define the fields or the states or the attributes, and we define the methods or functionalities
‫or behavior here, fields or states or attributes or variables.
‫And the methods represents the state and the behavior of the object.
‫Respective fields are used to store data while the methods or the behaviors perform operations.
‫So I'll follow the general syntax of creating a class to create a class called Car and see it in action.
‫Okay, I want from you to write this down on your notebook or your copy book.
‫I'll start with the class keyword.
‫The class name is Car followed by the curly braces.
‫And here I'll define the fields or the states.
‫And here I'll define the behaviors or the methods I want for this blueprint to to hold a state for the
‫interior and the year production.
‫Of this car.
‫Also, I need the speed of this car.
‫These are two attributes the year and the speed.
‫Now the methods.
‫I'll create a method called accelerate.
‫The returning type of this method is void.
‫I don't need to return anything.
‫It only increase the speed by ten so the old speed or the new speed will equal to the old speed plus
‫ten.
‫Every time I call this method, the speed will be increased by ten.
‫Another method will be brake.
‫Brake.
‫Every time I call this method, it will increase decrease the speed by five.
‫So in this car class, we have some information about the the car here, the car speed.
‫And also we have two actions accelerate and brake.
‫So this is the class.
‫Now let's move to create an object from this class.