プログラム言語に関する次の記述 a~c のうち, 適切なものだけをすべて挙げたものはどれか。 a 機械語やアセンブリ言語で作成されたプログラムは, 特定の CPU に依存することなく実行できる。 b コンパイラで変換されるプログラムは, 最終的には機械語に変換されてから実行される。 c 人間の言葉に近い規則をもったプログラム言語 (高水準言語) を活用すれば, 機械語では実行できない複雑な演算が実行できるプログラムが開発できる。
平成23年度 特別試験 ITパスポート試験 問81
This question's explanation and your answers so far.
問 81
Incorrectア
It lists a alone, but a itself is wrong. Machine language is the instruction code that the CPU interprets directly, and the kinds of instructions, the format of the operands, and their bit representation differ from one CPU architecture to another. Assembly language is a language that maps human-readable symbols (mnemonics) one-to-one onto those machine language instructions, so it too is specific to a particular CPU. In other words, a program written in machine language or assembly language cannot be executed as it is on any CPU other than the one it targets, so the statement that it does not depend on the CPU does not hold. It is also inappropriate in that it leaves out b, which is the correct statement.
Incorrectイ
It lists a and c, but both a and c are wrong, and the correct statement b is not included. a is wrong because, as noted above, machine language and assembly language depend on the CPU. c is wrong because a program written in a high-level language is also translated into machine language before or during execution, and the CPU executes nothing but machine language, so there is no operation that cannot be expressed in machine language yet can be executed with a high-level language. Because it selects two wrong statements, this choice is doubly inappropriate.
- ウ
正解 The correct answer is ウ, b. The only appropriate statement is b. Statement b — a program converted by a compiler is ultimately converted into machine language before it is executed — is correct because the only instructions a CPU can interpret and execute directly are machine language instructions (instruction codes expressed as sequences of 0s and 1s). A source program written in a language that people read and write, such as C, cannot be understood by the CPU as it is. The compiler therefore translates the whole source program at once and generates an object program (machine language), which is a form the CPU can execute. What actually runs at execution time is this machine language, not the source code itself. Even with a method such as an interpreter, which interprets and executes the program one line at a time, it is still machine language instructions that are finally passed to the CPU for processing. On the other hand, a is wrong because it denies the basic fact that machine language and assembly language depend on the CPU, and c is wrong because it claims that a high-level language makes possible operations that go beyond the capability of machine language. Therefore the only appropriate statement is b, and ウ, which lists b alone, is the correct answer.
Incorrectエ
It lists b and c. It is right that b is correct, but it is inappropriate because it also includes c. c says that using a high-level language makes it possible to perform complex operations that machine language cannot execute, but a program in a high-level language is also finally executed on the CPU as machine language, by way of a compiler or an interpreter, so the range of processing it can perform is the same as the range that can be written in machine language. The real advantages of a high-level language are that it can be written in a notation close to human language and mathematical formulas, which gives higher development efficiency and readability, and that it depends less on a specific CPU (high portability); its computing power itself does not increase. This choice does not satisfy the part of the condition all and only the appropriate ones that requires no extra item to be included.
- Organize programming languages by level. Machine language is the instruction code made of 0s and 1s that the CPU can execute directly, and assembly language is a low-level language that assigns symbols to those instructions; both depend on the CPU architecture. In contrast, high-level languages such as C and Java can be written in a notation close to human language and mathematical formulas, and the same source can be translated again for a different CPU, so their portability is high. However, even a high-level language is translated into machine language when it is executed, so the range of processing it can perform is the same as that of machine language.
- Grasp the role of language processing programs. A compiler is a method in which the source program is translated as a whole, an object program in machine language is generated, and only then is it executed, while an interpreter is a method that interprets and executes the program one line at a time. The methods differ, but the principle that what the CPU finally processes is machine language is common to both, and that principle is the basis for judging statement b correct and statement c wrong.