Class Vs Object
Class
A class is a User Defined Blueprint or Prototype.
It represents the set of properties or methods.
- Modifiers - Name should begin with a letter.
- Class name - The name should begin with a letter.
- Superclass - Preceded by the keyword extends.
- Interfaces - Preceded by the keyword implements.
- Body - The class body surrounded by braces, { }.
Example:
class <class_name>
{
field;
method;
}
Object
Object is a Real world thing like dog,table,fan,etc.
Objects have member variables.
An object consists of :
- State - It reflects the properties of an object.
- Behavior - It reflects the response of an object with other objects.
- Identity - It gives a unique name to an object.
Example:
ClassName n = new ClassName();
0 Comments