Difference between Class, Object, Variable, Method using real world concepts? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Difference between Class, Object, Variable, Method using real world concepts?

23rd Dec 2019, 7:17 AM
Luqman Hakim
Luqman Hakim - avatar
3 Answers
+ 5
In simple words Suppose you are chief (mens object) you have onion or patato (mens variable) and your duty is chop this onoion or patato using your hands (mens your hands is method that converts variable (onion or patato) to small pices).
23rd Dec 2019, 10:39 AM
Sumit Programmer😎😎
Sumit Programmer😎😎 - avatar
+ 2
Imagine a class as a blueprint of a building. Objects, are instances of that building, of the same blueprint. Each building can have attributes, corresponding to the way you made the class. Let's say for example the building is an ofifce. You can have variables such as how many workers are in the building, when it was constructed, name of the company and so on. The same building can also have methods, which are functions that do something. Let's say for example we want to celebrate something. We can run the function of the building, which was made in the blueprint you made earlier. Java is all based around objects containing variables and methods, and it all uses instances of objects. Take for example your main class. You are defining a class, for example called Program, and you make a method in it called main. Then the computer run's your class's main function and that's how the program runs. Hope I explained it good enough.
23rd Dec 2019, 7:32 AM
coddy
coddy - avatar
+ 2
Kindly complete the course and you will understand. https://www.sololearn.com/learn/Java/2151/
23rd Dec 2019, 8:27 AM
Avinesh
Avinesh - avatar