18.2k views
1 vote
6-Analyze and write a comparison of using C++ pointers and Java reference variables to refer to fixed heap-dynamic variables. Use safety and convenience as the primary considerations in the comparison. Write a report (7-15 lines)

User RedSIght
by
7.2k points

1 Answer

5 votes

Answer:

Check the explanation

Step-by-step explanation:

- C++ permits arithmetic among pointers but Java references not.

-java doesn’t support pointer explicitly, but Java uses pointer absolutely.

-Memory access via the pointer in C++ is basically unsafe but in java, robust security model does not allow arithmetic among pointers for this reason.

- References in Java are the strong types. Unlike c++ we cannot just cast int* to char* and just re-interpret the memory at that location.

-Manipulation of pointers is unsafe as compared to references in Java.

User Shailesh Katarmal
by
7.2k points