Last week a had pleasure to attend a technical interview, can’t tell you yet how it goes, still waiting for an email. Going through an experience like that, I, as a Software Engineer always want to make this easier for others (since I have been there). We all know how hard is to find the first job. It’s crucial to support each other in this difficult time — job search.
So one of the questions I received from the recruiter was: What is the difference between Object and Class?
And I hesitated! The difference was so obvious that it took me a moment to put the words together. Just to make sure it will never happen again, and you will also find the right words, let me explain:
What is coming’s first to a mind is: Object is an instance of a Class.
Many people get confused by the difference between class and object. The difference is simple and conceptual. A class is a template for objects.
A class defines object properties including a valid range of values and a default value. A class also describes object behavior.
An object is a member or an “instance” of a class. An object has a state in which all of its properties have values that you either explicitly define or that are defined by default settings.
In object-oriented terminology, a class is a template for defining objects. It specifies the names and types of variables that can exist in an object, as well as “methods” — procedures for operating on those variables. A class can be thought of as a “type”, with the objects being a “variable” of that type.
I hope that will help someone and from now on no one will hesitate!