Object – Instance of a class
While working with classes, we declare a reference variable of a class type and then, typically, using the operator new, we instantiate an object of that class type and store the address of the object into the reference variable.
The statement: Sum j = new Sum();
instantiate an object called j from class Sum.
Using the operator new to create a class object is called instantiation of the class.
public class Sum
{ double n1, n2;
void Outs(double a, double b)
{ System.ou.println(“The sum is ” + s);
}
public static void main(String[] args)
{ Sum j = new Sum();
j.n1 = 6.5;
j.n2 = 8.5;
j.Outs(j.n1, j.n2);
}
}