Object:-Object is a entity which
remain active in the system(Like we are a object which remain active in the
world).The Object can represent a person,a place,a bank account etc
which is handle by the program.So in programming every problem is analysed
in terms of objects and there nature of communication(Like in world we
communicate with others ).So when a program is executed these objects
reaming active in system and interact by sending messages to
each other.Remember that these objects do not know the internal details of each
others.Lets take an example how objects communicate:-
When you go to Bank you
have to communicate with some one to get information same as objects
communicate with each other to exchange information,like in above example the
program(software)developed to manage bank account data,that program will have
two objects one will be Customer and other will be Account(remember that at the
project level there will be so many objects will be created) and they will
communicate to do bank transaction.
Class:-We know every objects have data and methods
code to manipulate the
data.(like we have some attributes and functionality).The entire set of
data and methods code of an object can be made user defined data type using the class.Once a class is defined
we can create any number of objects belonging to that class.Example:-
Class Student
{
String
Name ;
int age;
Student(String nm,int ag)
{
Name=nm;
age=ag;
}
public
static void main(String arg[])
{
Student Steve=new Student("Stave",21);
Student John=new Student("John",19);
}
So
in above example student is a class,Stave and John are objects of Student class
No comments:
Post a Comment