Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


what is the difference between a java object reference and
c++ pointer?

Answers were Sorted based on User's Feedback



what is the difference between a java object reference and c++ pointer?..

Answer / aruna

object reference contains the address of the newly created
object by the JVM.

object reference is also a variable (variables are seen as
memory cells that can be accessed using their identifiers.
This way we did not have to care about the physical
location of our data within memory, we simply used its
identifier whenever we wanted to refer to our variable.)
using which we can access an object without knowing the
actual address or the location in which it is stored.

So,creating an object means, allocating some memory in heap
and intialise the instance variables and return the address
of the newly created object to the program.
thus, object reference contains the address of the memory
location(where the object is stored to which it is pointing
to)

JVM keeps track of these references.

In C++:

& is the reference operator and can be read as "address of"
* is the dereference operator and can be read as "value
pointed by".

For ex:

a= *c; // *(&b)
c= &b; // address of b (120) is stored in c.

where b=1000 and its stored in the memory location 120.
then the output of above two statements is:

a=1000;
c=120;


So, C++ pointer is nothing but a memory location in which
the value of the actual object it is pointing to is stored.


difference btn C++ pointer and object reference in java.

1. C++ pointer can point to any primitive data type where
as object reference in java point to an object.

Note:
whatever language you use, basic definitions would not
change.

Is This Answer Correct ?    6 Yes 1 No

what is the difference between a java object reference and c++ pointer?..

Answer / puneet

The above answer is wrong; Objects are stored on heap;
Refrence contains the way to reach out to the object.
pointers point to the location where a primitive type is
stored.

Is This Answer Correct ?    7 Yes 5 No

what is the difference between a java object reference and c++ pointer?..

Answer / chandra prakash sahu

Both have same purpose,becoz both point some memory location
,they hold the address of that location.Java reference
variable point the memory location of an object whereas C++
ponter point the memory location of any primitive type of
data type.

Is This Answer Correct ?    3 Yes 2 No

what is the difference between a java object reference and c++ pointer?..

Answer / ranabir chakraborty

both are the same concept the java object reference and c++
pointer.the object reference stored in the memory heap and
object are stored in stack.
Pointer are locate the address of the variables and object
reference locate the value of the variables.

Is This Answer Correct ?    11 Yes 15 No

Post New Answer

More Core Java Interview Questions

What is synchronization and why is it important in java programming?

0 Answers  


What is the file extension for java?

0 Answers  


What is the function of log?

0 Answers  


What do you understand by a Static Variable?

0 Answers   CGI,


What is matcher in java?

0 Answers  


What is the diffrence between inner class and nested class?

0 Answers  


How would you convert bytes to string?

0 Answers  


Explain differences between collection api and stream api?

0 Answers  


Is overriding possible in java?

0 Answers  


Why non nested classes in java are not having marked as protected access specifier

2 Answers   Google,


How do you identify independent and dependent variables?

0 Answers  


can abstract class have constructor how can you achive this ?

4 Answers   Fidelity,


Categories