Introduction of Objects and Class in Java Programming
Previous | Home | Next |
An object is a software bundle of related state and behavior.
An object is created based on its class
When an object is created, memory is allocated to hold the object properties.
A class is a blueprint or prototype from which objects are created.
A class is a collection of data and methods that operate on that data.
The data and methods, taken together, usually serve to define the contents and capabilities of some kind of object.
OBJECT
An object reference pointing to that memory location is also created. To use the object in the future,
that object reference has to be stored as a local variable or as an object member variable.
ClASS
A class is a collection of data and methods that operate on that data.
The data and methods, taken together, usually serve to define the contents and capabilities of some kind of object.
in the code below class Student is created
and in next one obj1 is the object which is created using new keyword
CLASS CREATION
public class Student //class creation
{
public String firstName;
public String lastName;
public int studentid;
OBJECT CREATION
{
// --- Create an object ---
MyObject obj1 = new MyObject();
// --- Use the object ---
obj1.printValues();
}
Previous | Home | Next |