Java Online Training In Andhra Pradesh and Telangana
Opening Hours :7AM to 9PM
Object Creation Or Instance Creation In Java
Object Creation Or Instance Creation: In Java
Before creating an object no memory allocate for the class variables at the time of declaration.without allocation of memory space no operation can be performed.To overcome this problem we must create sufficient memory space technically called instantiation of class(in general it is called object creation).
In java language object is instance of calss(instance allocation of memory space). Syntax: classname objref=new classname();
In the above syntax new keyword or special operator in java. It is used to allocate sufficient memory space for the all variable of class at runtime.
object reference can be userdefined name and that holds address of the new memory location.
Method calling and Variable Calling:
The main purpose of the object is to call the properties of class outside it. Syntax: objref.variablename;
which can be access the variable name of the class. objref.methodname();
which can be access method name of class.