Log In
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
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
in Object Oriented Programming

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.

Superb Answer

Related questions

2 votes
1 answer
It is possible to define a class within a class termed as nested class. There are __ types of nested classes 2 3 4 5
asked Aug 20, 2016 in Object Oriented Programming jothee 1.3k views
2 votes
2 answers
Implicit return type of a class constructor is not of class type itself class type itself a destructor of class type a destructor not of class type
asked Aug 20, 2016 in Object Oriented Programming jothee 828 views
0 votes
0 answers
Given the array of integers ‘array’ shown below: $\begin{array}{|c|c|c|c|c|c|c|c|c|c|} \hline 13 & 7 & 27 & 2 & 18 & 33 & 9 & 11 & 22 & 8 \\ \end{array}$ What is the output of the following JAVA statements? int[]p= new int [10]; int[]q= new int [10]; for ( int k=0; k<10; k++) p[k]= array [k]; q=p; p[4]=20; System.out.println(array[4]+":"+q[4]); $20:20$ $18:18$ $18:20$ $20:18$
asked Mar 24 in Object Oriented Programming jothee 58 views
0 votes
2 answers
Consider the following JAVA program: public class First { public static int CBSE (int x) { if (x < 100)x = CBSE (x+10); return (x-1); } public static void main(String[]args){ System.out.print(First.CBSE(60)); } } What does this program print? $59$ $95$ $69$ $99$
asked Mar 24 in Object Oriented Programming jothee 74 views