Computer AwarenessHardSSC CGL · RRB NTPC · IBPS PO · SBI Clerk

A program has an error in line 7 of 10. Which statement about how it will behave is correct?

  1. A. With an interpreter, no line executes; with a compiler, lines 1 to 6 execute before it stops
  2. B. With an interpreter, lines 1 to 6 execute before the error stops it; with a compiler, the error is reported before any of the program runs
  3. C. Both an interpreter and a compiler execute lines 1 to 6 and then stop at line 7
  4. D. Both report the error before executing any line of the program

Correct answer: B. With an interpreter, lines 1 to 6 execute before the error stops it; with a compiler, the error is reported before any of the program runs

An interpreter translates and runs one statement at a time, so earlier lines run first. A compiler translates the whole program first, so a syntax error stops the build before execution begins.

हिंदी में

किसी प्रोग्राम की 10 में से 7वीं पंक्ति में त्रुटि है। उसके व्यवहार के बारे में कौन-सा कथन सही है?

  1. A. इंटरप्रेटर के साथ कोई पंक्ति नहीं चलती; कंपाइलर के साथ पंक्ति 1 से 6 चलने के बाद वह रुकता है
  2. B. इंटरप्रेटर के साथ पंक्ति 1 से 6 चलने के बाद त्रुटि उसे रोकती है; कंपाइलर के साथ प्रोग्राम का कोई भाग चलने से पहले त्रुटि बता दी जाती है
  3. C. इंटरप्रेटर और कंपाइलर दोनों पंक्ति 1 से 6 चलाकर पंक्ति 7 पर रुकते हैं
  4. D. दोनों प्रोग्राम की कोई पंक्ति चलाने से पहले त्रुटि बताते हैं

उत्तर: B. इंटरप्रेटर एक बार में एक कथन अनुवाद करके चलाता है, इसलिए पहले की पंक्तियाँ चल जाती हैं। कंपाइलर पहले पूरे प्रोग्राम का अनुवाद करता है, इसलिए सिंटैक्स त्रुटि निष्पादन शुरू होने से पहले ही बिल्ड रोक देती है।

More Computer Awareness questions

Exams that ask this topic