[Solved] Why ArrayIndexOutOfBound Exception can be caught in Java, but C++ program crashes instead? [duplicate]


Since you were asked this question in an interview, the interviewer was probably trying to gain some knowledge about your understanding of principles behind C++ design.

In this case, the principle the interviewer was looking to discuss is that in C++ you don’t pay for things that you do not explicitly request. Although bounds checking can be ridiculously cheap in terms of CPU, it is not free. Implementing it at the language level would make you pay for what you did not request explicitly, thus violating one of C++ fundamental design principles.

solved Why ArrayIndexOutOfBound Exception can be caught in Java, but C++ program crashes instead? [duplicate]