+ 2
Difference between Class, Object, Variable, Method using real world concepts?
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).
+ 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.
+ 2
Kindly complete the course and you will understand.
https://www.sololearn.com/learn/Java/2151/