REGISTER FREE to Receive Instant Job

Friday, 7 November 2014

Reference Variable in Java

Reference Variable:- is an implicit pointer that contains the reference of a class object. In Java, objects are dynamically created. Hence, they don’t have names. They are referred using the name of their reference variable.

Example:
public class Rectangle
{
private int l, b;

public void Rectangle(int x, int y)
{
l = x;
b = y;
}

public void display()
{
System.out.println("Length = " + l);
System.out.println("Breadth = " + b);
}

public int area()
{
return l * b;
}

public void setDimension(int x, int y)
{
l = x;
b = y;
}
}
Syntax of creating object of a class-

className ReferenceVariable = new className();

OR
className ReferenceVariable;

ReferenceVariable = new className();

1 comment:

Popular Posts

Powered by Blogger.

About Me

My photo

JobsAcid is a 'job search engine' to provide finding a job on the internet easier for the user. It has designed as huge selection of job offerings on the same search engine.