45. Which translation method converts all source code into machine code for later execution?

Answer: B

Explanation:

Compiler

A compiler is a translation method that converts all source code into machine code, allowing the program to be executed later without the need for the original source code. This process typically involves several stages, including lexical analysis, syntax analysis, semantic analysis, optimization, and code generation.

A) Interpreter

An interpreter translates source code into machine code line by line and executes it immediately, without producing a separate executable file. This method does not convert the entire source code at once, making it distinct from a compiler.

B) Compiler

As stated, a compiler translates the entire source code into machine code prior to execution, enabling the program to run independently of the source code. This method is efficient for execution since the translation occurs only once, and the resulting machine code can be executed multiple times.

C) Assembler

An assembler converts assembly language, which is a low-level programming language, into machine code. While it performs a similar function to a compiler, it specifically works with assembly language rather than high-level programming languages.

D) Operating system

An operating system is not a translation method; rather, it is system software that manages computer hardware and software resources and provides common services for computer programs. It does not convert source code into machine code.

Conclusion

The compiler is the only option that correctly describes a translation method that converts all source code into machine code for later execution. In contrast, the interpreter executes code immediately without full conversion, the assembler focuses on assembly language, and the operating system manages resources rather than translating code. Therefore, the compiler is definitively the correct answer.