My neighbor is taking \"Intro to Java\", and asked me to help explain a few of the first-day concepts. I realized that since I do this everyday, I don\'t have the beginner\
If your neighbor is into classical philosophy, classes are Plato's Forms and objects are the things we see everyday that are based on the Forms.
Class can be defined as the blue print or template which defines attributes,actions,states for the entity and Object would be the one which would be implementation for the entity.
One of the examples I use during my java courses is the Human
class.
Everyone reading this is a Human
(I least I hope so !), we all have our differences our resemblances but at the end we're all Human
(After all).
Each Human
(known as an instance or object) has specific characteristics such as the eyes color or the voice which are the fields (you called that variables, but the right name would be fields). But the values are different from an Human
instance to another.
There is also a common knowledge, shared with the humanity, principles like the "Pythagorean theorem". This knowledge is common, it can be interpreted as a static field (I know it's an exaggeration) which means that this knowledge is not only contained in one human but in the humanity.
Every Human
can do things such as walking, speaking etc. this is known as method, walking is the same for everyone, but when I walk, not everyone walk. The act of walking only affects the Human
instance which does this, but still it's defined by the Human
class
If you want to get deeper in OOP, Teaching OOP to non-programmers
If and only if he is familiar with Plato's Theory of Forms, you can make an analogy where classes are like Plato's forms and objects are like Plato's real world objects.
See this post for a full description.
Class: Girl
Object : that girl, this girl, my girl...umm maybe not.
Yea all girls should have the properties of a Girl (class in this case).
class: custom variable type
object: a variable, whose type is custom defined (if you don't count the built-in ones)