Which statement best describes the difference in execution time between a compiler and an interpreter?
Think about when the translation happens and how it affects running speed.
A compiler translates the whole program into machine code before running it, so the program runs faster during execution. An interpreter translates and runs code line-by-line, which is slower.
When are errors typically detected in a compiled language compared to an interpreted language?
Consider when the code is checked in each approach.
Compiled languages check for errors during the compilation step before running the program. Interpreted languages check for errors as each line runs, so errors appear during execution.
You want to develop a program that needs to run very fast and will be used many times without changes. Which approach is better and why?
Think about speed and how often the program will be run without changes.
A compiler translates the entire program into machine code once, so the program runs very fast on repeated executions. Interpreters translate code every time it runs, which is slower.
Which statement correctly compares memory usage between compiled and interpreted programs during execution?
Consider what is stored in memory while the program runs.
Compiled programs run as machine code directly, so they usually use less memory. Interpreted programs need extra memory for the interpreter and source code during execution.
Some languages use both compilation and interpretation (like compiling to bytecode then interpreting). What is the main advantage of this hybrid approach?
Think about how compiling once and interpreting later affects speed and compatibility.
The hybrid approach compiles source code into an intermediate form (bytecode) once, then interprets that bytecode on different platforms. This improves speed compared to pure interpretation and allows flexibility across systems.