I know that this will sounds a bit stupid but I would like to ask what does "CLASS" and "OBJECTS" really means.
Yes, I can find a lot of meanings and explanations of it but I can't really catch what really it is.

can someone explain it in the simplest way.

A class is a recipe.
An object is what you have cooked with it.

commented: Nice. +5

I would say that an object is the reuse of a particular piece of code ( Which is in the class) that is used a lot of times in a program.
So to prevent the user from typing the same code multiple times you create a class in which common pieces of code reside. So then if you want to change a certain thing in your code you just change the code in the class itself and then it is applied to all the other objects of that class. It is the same as a CSS file applies to all HTML objects. So instead of changing each HTML element separately you only have to change the CSS file property. In this case you can see the HTML elements as Objects and the CSS file as the class.

This is the idea behind Classes and objects and it also gives the programmer the opportunity to design a program in an object orientated manner. This is how it should be used but I think it was intended with data abstraction in mind.

(This is based on my experience with Java - other languages may vary)
A class is the template from which an object is created. A class defines object, an object instantiates the class.
The main difference is how they go about existing on the stack.
When a class is loaded, space is allocated for any static variables. These are shared by all objects of the class, or can be accessed without any obects being created (see java.Math, for example).
When an object is created, it gets a piece of the heap to store its instance variables, which belong to it alone.

As a consequence of this, static and instance fields behave quite differently. Suppose you have a class Car which has a public static int field called "NUMBER_OF_WHEELS". This is a static, so every Car that exists as an instantiation of this class will have the same NUMBER_OF_WHEELS. Suppose that Car also has an instance field - private Color color. This field is allocated for each Car, and can't be referred to without the reference to that particular car - and each car has an independent value for "color". You can't get at Car.color, because it doesn't exist. If I were to change the NUMBER_OF_WHEELS field to 3, every car loses a wheel. If I give my car a new paint job (and change its "color" to Color.PLAID, for example) your car is safe (you can keep your polka dots).


You should note that although all three of the answers you see here look quite different, they're all different ways of saying much the same thing.

I'm approcimiately with @ddanbe: A class describes how an object will behave, an object behaves that way. This is very cool because we humans are used to dealing with actual real world objects that have behavior conditioned on what class of object they are: ATMs behave one way, and automobiles another way; and we expect other automobiles to be like our automobile; and we expect an ATM to be like another ATM. So using classes and objects in programming makes programming more familiar to us, and that makes us more efficient programmers. At least that's the idea.

Thanks everyone for your replies. I really appreciate it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.