The Gateway to Computer Science Excellence
+2 votes
1.1k views

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
in Others by Veteran (105k points)
recategorized by | 1.1k views

1 Answer

+1 vote

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.

by Boss (23.8k points)
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,645 questions
56,597 answers
195,837 comments
102,140 users