Page 11 - JAVA Programming
P. 11
10
Class
In all Programming Language, We create variable of built in data
types like int a;. This statement declares a variable ‘a’ of data types
‘int’ which means that ‘a’ can hold any integer data.
Similarly we can create a variable of user defined data types like
Student s;. Here, ‘Student’ is a user defined data type and ‘s’ is
variable of that.
In order to create a user, define data type, java provides that concept
of class. A class is a blueprint/template from which individual object
and created.
A class consist of data and methods. A class is a collection of objects
of similar type of object. Classes are user defined data type. Once has
been defined, we can create any number of object belonging to that
class.
• For Example :
class person
{
string name; int age;
void accept (String n, int a)
{
name=n;
age=a;
}
void display()
{
system.out.print1n(“Name=’+name);
system.out.print1n(“Age=’+age);
}
}