...Syntax errors are treated differently in C++ (Compiler) and Java (Interpreter), as the interpreters are used to interpret the source line by line, whereas, the compiler (C++) compiles the whole code at once and displays all the errors at a time.
Usually, the compiler does not generate any file (object or executable) and stop compiling if there is a compilation error. However, some compilers continue compilation to show all the syntax errors at once, for example C++. Conversely, while dealing with objects in compilers (C++), only a few object files produced, but not at all.
The interpreter does not differentiate between exception and syntax error, it continues to interpret and execute... Discussion...