answersLogoWhite

0

Yes. If you simply write:

x = new SomeClass();
y = x;

will make the variable y refer to the same object that variable x is referring to.

User Avatar

Wiki User

15y ago

What else can I help you with?

Continue Learning about Engineering

What is aggregation in C plus plus?

Aggregation and composition are two sides of the same coin. Both an aggregate and a composite object encapsulate one or more sub-objects. But while a composite object owns its sub-objects, an aggregate object does not. That is, when a composite object is destroyed, its sub-objects are also destroyed. But with an aggregate object, the sub-objects are not destroyed. Aggregate objects typically use references or pointers to refer to their sub-objects, whereas composite objects typically use member variables or pointers to refer to their objects. In essence, a composite object instantiates its own sub-objects, whereas an aggregate object's sub-objects must be passed to it, typically via the constructor. In complex models you will often find a combination of composition, aggregation and inheritance, even within the same object.


Write a program to copy the value of one string variable to another variable?

You can have two String variables (note that String variables are object references) refer to the same String object like so: String str1 = "Hello"; String str2 = str1; Now the str1 and str2 are references for the same String object containing the word "Hello". If you actually want a new String object with a copy of the contents of the original String, you use the String constructor that takes a String argument, like so: String str3 = new String(str1); Now str1 and str3 refer to SEPARATE String objects that happen to contain the same sequence of characters (the word "Hello"). Since Strings objects in Java are immutable, they can be shared without worrying about the contents used by one variable being upset by the use through another variable as might happen with char[] arrays in C or C++ so the first method is probably sufficient for most cases.


What is type equivalence in programming language?

Type equivalence occurs when two variables are of the same type. For example, if both variables are int (integer variables), they are of equal types. Equivalence can also occur with two different types that are compatible with each other.


Quantitative variables can be separated into what two types?

nominal and ordinal is wrong; those are the two types of qualitative variables. Ratio and interval are the two types of quantitative variables.


If two references are having same hashcodes is that mean those two are refering to same object?

Possibly. It could also mean that the two references are referring to two different Objects, which contain the same data.

Related Questions

What are the two variables that are important in momentum?

The two important variables in momentum are the mass of the object and its velocity. Momentum is calculated by multiplying an object's mass by its velocity.


Can you store the two variables with different values but having same name in session object?

Yes you can store it but the value which is assigned at the last will be accessed when the value is displayed.


What are the two variables that affect an objects kinetic energy?

The two variables that affect an object's kinetic energy are the object's mass and its velocity. Kinetic energy is calculated using the formula KE = 0.5 * mass * velocity^2, so both of these variables play a crucial role in determining the amount of kinetic energy an object possesses.


What is the difference between reference and hash code in java?

Cat oldCat = new Cat(); Cat newCat = new Cat(); Cat oldCatRef = oldCat; In the above example, oldCat and oldCatRef are references to the same object. Since they refer to the same object, their hashcodes will be equal. But oldCat and newCat do not refer to the same object. They are references to two different objects. But they might have the same hashCode based on their implementation. hashCode is simply a method in Object class which you can override.


What does Correlation of plus 1.00 mean?

It mean that there is no correlation between the two variables. The variables are the same.


Can you have two variables in the same equation with the same value?

Yes, but it is not a common occurrence.


What are two variables that acceleration depends on?

Acceleration depends on the mass of the object and the net force acting on it.


What is aggregation in C plus plus?

Aggregation and composition are two sides of the same coin. Both an aggregate and a composite object encapsulate one or more sub-objects. But while a composite object owns its sub-objects, an aggregate object does not. That is, when a composite object is destroyed, its sub-objects are also destroyed. But with an aggregate object, the sub-objects are not destroyed. Aggregate objects typically use references or pointers to refer to their sub-objects, whereas composite objects typically use member variables or pointers to refer to their objects. In essence, a composite object instantiates its own sub-objects, whereas an aggregate object's sub-objects must be passed to it, typically via the constructor. In complex models you will often find a combination of composition, aggregation and inheritance, even within the same object.


If two graphs have exactly the same shape what can you tell about the variables?

If two graphs have exactly the same shape, it indicates that the variables are proportional to each other. This means that as one variable increases or decreases, the other variable changes in a consistent and fixed ratio.


The natural frequency of an object depends on its?

It depends on two variables v : speed of sound within this object L : main lenght of this object The natural frequency of the object will be v/L


When an equation has two variables there is a number of values that the two variables could have?

If an equation has two variables, we'll call them (x,y), the variables can be any value as long as both sides of the equation have the same result. If the equation was x = y, then the variables could be (1,1), (2,2), (3,3),etc...


A graph of two simultaneous linear inequalities in two variables that have no intersecting regions must contain two lines with the same slope?

A graph of two simultaneous linear inequalities in two variables that have no intersecting regions must contain two lines with the same slope.