Skip to content

平成25年度 秋期 ITパスポート試験 問55

This question's explanation and your answers so far.

問55
頻出度★☆☆

プログラムの実行方式としてインタプリタ方式とコンパイラ方式がある。図は,データを入力して結果を出力するプログラムの,それぞれの方式でのプログラムの実行の様子を示したものである。a,bに入れる字句の適切な組合せはどれか。 方式a の図: - ソースプログラム →(矢印)→ [a] - データ →(入力)→ [a] - [a] →(出力)→ 結果 方式b の図: - ソースプログラム →(矢印)→ [b] - [b] →(矢印)→ 目的プログラム - データ →(入力)→ 目的プログラム - 目的プログラム →(出力)→ 結果

出典 平成25年度 秋期 ITパスポート試験 問55
解説

問 55

  • Incorrectア

    This combination makes both a and b interpreters, but the diagram for b contains an object program produced from the source program, and the data is fed into that object program. An interpreter does not create an object program; it interprets and executes the source program directly, so calling b an interpreter contradicts the figure.

  • イ

    正解 The decisive clue for telling the two methods apart in the figure is whether an object program appears along the way. In the diagram for method a there is no object program: the source program and the data both go straight into box a, and the result comes out of it. This is the behavior of reading and interpreting the source program line by line and processing it on the spot at run time, which is exactly what an interpreter does. In the diagram for method b, by contrast, the source program first goes into box b, and b produces an object program. The data is fed not into b but into the generated object program, and the result comes out of that. This is the flow of translating the whole source program into machine language (the object program) before execution and then running the already-translated program, which is what a compiler does. Therefore a is Interpreter and b is Compiler, so the correct answer is イ.

  • Incorrectウ

    This combination swaps a and b. The diagram for a has no object program, so it is an interpreter rather than a compiler, and the diagram for b does have an object program, so it is a compiler rather than an interpreter. Both are the other way around.

  • Incorrectエ

    This combination makes both a and b compilers, but in the diagram for a the data goes directly into box a and the result comes out without passing through any object program. The role of a compiler is to translate and output an object program; it does not itself take in data and produce a result, so treating a as a compiler is wrong.

ここがポイント
  • An interpreter interprets the source program line by line and processes it on the spot at run time, so it does not create an object program. Because it translates on every run, execution is slow, but it makes it easy to develop while trying things out.
  • A compiler translates the entire source program into a machine-language object program all at once before execution. At run time the already-translated object program processes the data, so execution is fast. Whether an object program appears in the figure is the decisive clue for telling the two methods apart.

Your answers