This article is solely for all beginner programmers, who are learning object oriented programming language e.g. Java, C++ or C# and aspire to do well on any programming interview.
Difference between class and object is one of the most common question, you would like to ask a fresher coming out from college or training institute, but you would be surprised how many beginner Java programmers struggle with this question.
Class and
Object are two pillars of Object Oriented Programming (OOPS) and a good understanding is must, but when you ask this question apart from theoretical and bookish answer that
"class is a blueprint and objects are actual things created out of those blueprint", you would hardly get anything substantial. Though that answer is correct and works perfectly, it doesn't differentiate between a programmer, who has just mugged the answer, or the one who truly understand the difference between class and object. So, if I receive that answer, I usually ask them to create a class and explain how objects are created in program, let's say to represent an
Employee,
Student or simply a
Car. If programmer truly understand
what is a class and
what is an object, it will do that in no time, but if he has just mugged up the answer, then he will be totally confused. Point is to understand the difference between class and object, not to mug up for an interview, Why? because if you know your class and object, it would be lot easy for you to work with an object oriented programming language like Java or C#. To give you some more example of class and object, if
Car is a class than
Merc,
Audi and
BMW are objects. If Television is class than Sony Bravia, Samsung Smart tv are its object. If Smartphone is a class then iPhone, Samsung Galaxy and Nokia Lumia are their object. In an object oriented application, generally nouns are represented using class, for example in finance domain Order, Trade, Instruments are classes. In E-commerce domain
Payment,
Order,
Products are some example of classes.