I'm in a job hunting. And in my CV I placed a skill list like:
The most common question I got is: "hem, since you are familiar with both C++ and Java, can you tell some similarities or difference between the two languages."
And I just don't know how to answer, what I said is basically some language level details like they have some different keywords like
abstract and so on. I want to see some comparison in high level like the difference in
garbage collector and so on.
At least I want to go deep into one side, that is the resource management. Java has no lifetime for an object, this is managed by the
garbage collector, and in C++ you need to carefully manage your resource especially for the
heap. In C++ we can greatly reduce the memory leak by introducing
RAII, using object to manage the heap memory, and so is for the other resources like
lock and so on. I am not sure what to do in Java, because the garbage collector can only be a nice tools for the management of heap memory (AFAIK ).
Question: How can we manage other resources in an situation that we do not have a destructor to do all these automatically? Do we need to manually guarantee that the resources be returned in a right place. And how?