In computers, the source code or program is translated into machine code by different methods. Machine code is also known as object code.
Assembler converts source code written in assembly language into machine code and then that machine code is executed by a computer.
A compiler converts high-level language program code into machine language and then execute it. High-level languages are C and C++.
Interpreter converts source code into the intermediate form and then convert that intermediate code into machine language. The intermediate code looks same as assembler code.
During source code conversion variables and arithmetic operators like +, -, *, / are extracted from the code and then calculated.
In a compiler, all the code is converted at one time and the error report is generated for the whole program. In interpreter, the code is converted line by line and if an error occurs in the code then program execution stops.
In java language, compiler and interpreter work together to generate machine code.