Question 31
Hard
Assertion (A): A program translated by a compiler generally runs faster than the same program run through an interpreter.
Reason (R): A compiler translates the whole program into machine code before it is executed.
Choose the correct answer.
A
Both A and R are true, and R is the correct explanation of A
B
Both A and R are true, but R is not the correct explanation of A
C
A is true, but R is false
D
A is false, but R is true
Correct Answer:
A
Explanation:
Both A and R are true, and R explains A.
Because the compiler finishes all translation in advance, the computer runs ready-made machine code each time without stopping to translate.
An interpreter translates each line as the program runs, and that repeated translation is what slows interpreted programs down.