recategorized
3,262 views
2 votes
2 votes

When one object reference variable is assigned to another object reference variable then

  1. a copy of the object is created
  2. a copy of the reference is created
  3. a copy of the reference is not created
  4. It is illegal to assign one object reference variable to another object reference variable
recategorized

1 Answer

1 votes
1 votes

B is Ans.

Assigning Object Reference Variables Concept:---

1.We can assign value of reference variable to another reference variable.

2.Reference Variable is used to store the address of the variable.

3.Assigning Reference will not create distinct copies of Objects.

4.All reference variables are referring to same Object.

5.Assigning Object Reference Variables does not –

       i.Create Distinct Objects

        ii.Allocate Memory

.        iii.Create duplicate Copy

Consider This Example –

Rectangle r1 = new Rectangle();

Rectangle r2 = r1;

r1 is reference variable which contain the address of Actual Rectangle Object.

r2 is another reference variable

r2 is initialized with r1 means – “r1 and r2” both are referring same object , thus it does not create duplicate object , nor does it allocate extra memory.

Answer:

Related questions

2 votes
2 votes
1 answer
1
go_editor asked Aug 20, 2016
2,991 views
It is possible to define a class within a class termed as nested class. There are __ types of nested classes2345
2 votes
2 votes
1 answer
2
go_editor asked Aug 20, 2016
1,633 views
Implicit return type of a class constructor isnot of class type itselfclass type itselfa destructor of class typea destructor not of class type
2 votes
2 votes
3 answers
4