answersLogoWhite

0

For an object named Point you would declare an object reference variable like this:

Point p1;

The name p1 can be any valid variable name that you want. Note that p1 does not yet refer to an actual object yet, you have just created a reference to one (kind of like a pointer in C). To set p1 to actually refer to an instance of the object Point you could do something like this:

p1 = new Point();

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

Why you use the reference variable?

The reference variable controls an object. Without the reference variable, you would have no way of accessing the object.


How do you make variables in game maker 7?

Depends, if you wish to create a variable that is only controlled by one object, then simply declare: "variable_name=x" with x being whatever value. Although, if you want a variable that is controlled by any object, then name the variable: "global.variable_name" the global part insures the variable will be available for reference to any object.


Difference between reference variable and instance variable?

An object is the actual storage space in memory in which some collection of data resides.A reference variable is a variable which refers to the memory location of an object.Look at the pseudocode below:Object obj = new Object();Here obj is the reference variable, and the data to which it refers is the object.


What type of reference is C19?

A reference variable is used to refer to or give access to an object. A reference variable is declared to be of a particular type and that type can not be altered.


What happens if a final keyword is applied to identifier?

The final keyword indicates that a variable (identifier) can not change his value. In case the variable refers to a reference variable (an object) the values of variables inside (the object) can change but the reference can be reassigned (to another object).


What is reference data types in java?

A reference variable is used to refer to (or access) an object. A reference variable is declared to be of a specific type and that type can never be changed. Ex: ArrayList lst = new ArrayList(); The above line creates a reference variable lst which refers to an ArrayList object


Declare the variable longPtr to be a pointer to an object of type long?

long *longPtr;


How do you return an object in java?

With the command return, followed by an object variable. In the method header, you have to declare the return type as the class of the object.


What is a variable used for in Python?

A variable is used to store information. As an example say you are asking someone for their favorite food, and want to store the answer in a variable called favoriteFood: favoriteFood = input("What is your favorite food?") Now if you print the value of favoriteFood (using print(FavoriteFood)) you will see that it has been saved in that variable. You can store any type in a variable, such as number, a string, or even an object.


What is reference variable and explain its uses?

Reference variable is an alias name for a previously defined variable. Its use is that the same data object can be referred by 2 names and then can be used interchangeably.


Explain reference variable and how it is different from pointer variable?

In JAVA, all variables are reference variables, and there are no pointer variables. Even though the platform may implement them as pointers, they are not available as such. In C, no variables are reference variables. They are a C++ enhancement. In C++ a reference variable is syntactically the same as a pointer variable, except that the use of the indirection operator (*) is implicit. You do declare reference variables slightly differently than pointer variables but, once you do so, they can be treated as non-pointer variables. Reference variables also cannot be redefined once they have been initialized to point to some object. They are const. Structurally, there is no difference between a pointer variable and a reference variable. They are both still pointers. The compiler just makes it easier to treat reference variables and non-pointer variables the same way.


What is a polymorphism in java programming?

Polymorphism can be considered as the ability of one thing being multiple other things (though partially or fully). Am I confusing you? I believe yes. To put it in simpler words, any java object that can pass more than one Is-A test can be considered polymorphic. Other than objects of type Object, all Java objects are polymorphic in that they pass the IS-A test for their own type and for class Object. Remember that the only way to access an object is through a reference variable, and there are a few key things to remember about references: • A reference variable can be of only one type, and once declared, that type can never be changed (although the object it references can change). • A reference is a variable, so it can be reassigned to other objects, (unless the reference is declared final). • A reference variable's type determines the methods that can be invoked on the object the variable is referencing. • A reference variable can refer to any object of the same type as the declared reference, or-this is the big one-it can refer to any subtype of the declared type! • A reference variable can be declared as a class type or an interface type. If the variable is declared as an interface type, it can reference any object of any class that implements the interface.