"A reference in Java Script affectively means a variable data type whose value takes the form of an address. A variable in Java Script is a terms that is used for an item of data that is named by an identifier. Each of these variables has a type which it can be classified under, such as 'int' or 'Object' and a scope. Commonly, in Java, variable have to be one of two types: 'Primitive' type or 'reference' type, and cannot be both. This statement leads to major simplifications within the syntax involved in certain expressions that are relative to C++. This provides a vast amount of flexibility for programmers using Java Script, but can lead to errors that are undetectable when compiling, and are only shown to exist when the written program is actually running.
A reference variable in Java contains an address, or a reference to an address (similar to pointer variables in C++). Java does not, however, allow this address to be arbitrarily (randomly) edited or changed in any way. This goes for pointer variables in C++ as well. So, reference variables are similar to pointer variables in C++. They provide a method through which to access another variable or memory address that has a variable, and allow changes to the data within the afore-mentioned memory address. A reference variable provides direct access to this memory address. "
Reference variable is one which holds reference(points to) to a an instance(object) of a class.. If I say, Box b..then b is a reference variable of type Box(where Box is a class).Now it can hold reference to any instance of class Box or of classes derived from it as described below:
Box b=new Box(); new Box() creates a instance of class Box.So b is now pointing to an object of class Box or in other words holding a reference to an instance of class Box.
A reference variable can hold the reference of an object, but when we call any method by using reference variable then always call only those method which type of object we create. Class Animal{ void eat(){ sop("animal class"); } } Class Dog extends Animal{ void eat(){ sop("dog class"); } } Class Cat extends Animal{ void eat(){ sop("cat class"); } } Animal a = new Animal(); Animal b = new Dog(); Animal c = new Cat(); a.eat();// animal class b.eat();// dog class c.eat();// cat class
Java variables refer to things that contain data which undergoes change when a particular program is executed. It is necessary to declare a variable i.e. To notify the compiler and the type of the variable before using a variable. There are different types of variables in a java program. Some of them are primitive type and reference type. A reference type of variable is generally defined as variables where their names can evaluate to the address of the location found in the memory. The object that is referenced buy the variable is stored in this place. Thus it is known as reference variable due to its function in a Java program. A variable can either be primitive type or a reference type and cannot be both at the same time. Each has its own specific needs and requirements.
A reference variable is declared to be of a specific type and that type can never be changed. Reference variables can be declared as instance variables ,static variables, method parameters, or local variables.
These are names given to various programming element such as variables, function, arrays.It is a combination of letter, digit and underscore.It should begin with letter. Backspace is not allowed.
A variable is something that can store data, such as numbers and words. One of the common types of variables is called "int", which can store numbers. Creating a variable is simple: Int myVar; "int" is the data type of the variable, and "myVar" is the name of the variable, you can choose almost any name you want for your variables. Then you can assign a number to this variable, you can even use negative numbers: MyVar = 5; Notice how you do not need to type "int" again, you only need to do it once when you create the variable. Here's how to add numbers to variables: MyVar = myVar + 4; OR myVar += 4; When you do either of these it will add 4 to the value of myVar, which means myVar now equals 9. (5 + 4 = 9) You can also use subtraction: - Multiplication: * Division: / and Modulus: %
Another important data type is the String, a String can store words and letters, and behaves much like an int. String myVar; myVar = "Hello"; myVar += " there, Sir."; Now, like we did with the int earlier, myVar equals "Hello there, Sir." One last thing, you can add different variables together, but they must be the same data type: MyVar += anotherVar;
A variable that does not have the value with it , but it refers to another variable for the values ....
Example--: Int I,j; I=15; j=I; If you are using the object j in a class and accessing a file from another class then you have to take the help of the DOT(.) operator.... Here "j" is the reference variable and I is the value variable....