what are classes? classes are the blueprint of a user defined data type. the classes define the characteristic of a data type. for example consider a primitive data type. int, it can hold variables of type integer. Likewise the classes are data types with definite characteristics defined in them. Classes written in a program contribute contribute to its output only when instantiated by an object. What is an object? An object is an instance of a a class, that is an object can be considered as a variable of the user defined data type. Once an object instantiates a class, it holds all the characteristic associated with that class. An object can be used to access the variables and methods in the class.
Variables have certain values assigned to them the methods consists of few set of statements for operations which includes either manipulation of the variables to produce a desired output or executing short commands such as printing a sentence. Consider a recipe for a pizza, A class is like a recipe, like a class, a recipe lists out all the ingredients needed the procedure to obtain the desired result. The ingredients are like the variables and the procedures are like the methods. recipe itself ain’t a pizza, you have to do what the recipe asks you to do, just like the objects instantiates the class. The pizza is like an instance of the recipe, just as the object is an instance of the class!
You may build as many pizzas as you want from the same recipe, likewise you can create as many objects as you want for one class. The final dinner table may have different flavored pizzas using different recipes just like a program uses uses different classes for generating the desired output!! Thanks for watching this video.
You may wanna check out few other videos as well, about java, and even Colleges and stuffs, they might be worth your time. Well Stay tuned for more such videos ! This is NerdNess and don’t forget to subscribe if you like it!