Computer Knowledge
Programming Languages and Compilers
1,170 Questions
Programming languages and compilers involve the rules, syntax, and semantics used to write and execute software programs. Key areas include scripting languages, object oriented concepts, and parsing algorithms like top down parsers. Practice these computer science questions to build proficiency for technical and computer knowledge exams.
Object oriented languagesScripting languagesCompilers and parsersProgramming syntax
Programming Languages and Compilers Questions
-
programming languages
-
register counter
-
location counter
-
instruction counter
A
Correct answer
Explanation
Macro languages allow programmers to define shorthand for sequences of instructions, which are then expanded by a macro processor. This system provides a way to extend a base language, making it a specialized form of programming language. Unlike counters, which track addresses or values, macro languages focus on code abstraction and generation.
-
imperative
-
declarative
-
assembler directive
-
all of these
-
system parsing
-
programming parsing
-
bottom up parsing
-
none of these
C
Correct answer
Explanation
In compiler theory, parsing is the process of determining the grammatical structure of a sequence of tokens. The two primary strategies for this are top-down parsing, which builds the parse tree from the root down to the leaves, and bottom-up parsing, which starts from the leaves and works up to the root. These two methods cover the vast majority of parsing algorithms used in computer science.
-
storage allocation
-
lexical analysis
-
semantic analysis
-
none of these
A
Correct answer
Explanation
A compiler is divided into analysis and synthesis phases. The synthesis phase is responsible for taking the analyzed source code and producing the target machine code, which involves storage allocation for variables and the actual generation of instructions. Lexical and semantic analysis are part of the analysis phase, which occurs before synthesis.
-
to convert high level language into machine level language.
-
to convert high level language into assembly language
-
to convert assembly language into machine level language
-
all of these
A
Correct answer
Explanation
The primary definition of a compiler is a program that translates high-level language (HLL) source code into machine-level language (object code). While some compilers may output assembly language as an intermediate step, the ultimate task that distinguishes a compiler from an assembler is the conversion from a high-level abstraction to a machine-executable format. Option C describes an assembler, not a compiler.
-
BASIC
-
FORTRAN
-
C
-
None of these
C
Correct answer
Explanation
Unix was famously rewritten in the C programming language in 1973, which made it highly portable compared to earlier operating systems written in assembly.
B
Correct answer
Explanation
ASCII was developed by the American National Standards Institute (ANSI) to provide a standard character encoding for electronic communication. It represents text in computers and other devices.
-
Replicator
-
Compiler
-
Converter
-
Operator
B
Correct answer
Explanation
A compiler is a specialized program that translates source code written in a high-level programming language into machine-readable code (machine language).
-
sequencing
-
alteration
-
iteration
-
all of the above
D
Correct answer
Explanation
Structured programming is built on three fundamental control structures: sequence, selection (often called alteration), and iteration (loops).
-
reproductive
-
encapsulated
-
extensible
-
none of above
-
Control words
-
Reserved words
-
Control structures
-
Reserved keys
-
None of these
B
Correct answer
Explanation
Reserved words (or keywords) are words in a programming language that have a predefined meaning and cannot be used as identifiers (like variable or function names) by the programmer.
-
Machine Language
-
BASIC
-
Any high level programming language
-
Specific programming language
-
None of these
A
Correct answer
Explanation
Computers operate at the hardware level using binary signals, which are represented by machine language. All other languages must be translated into machine language for the CPU to execute them.
-
COBOL
-
CORAL
-
C
-
FORTRAN
-
None of these
-
binary language
-
low-level language
-
high-level language
-
machine language
-
None of these
B
Correct answer
Explanation
Assembly level is a low-level language.
-
Interpreter
-
Application program
-
Compiler
-
Assembler
-
None of these
C
Correct answer
Explanation
A compiler is a program that translates source code written in a high-level language into machine-readable object code. An interpreter executes code line-by-line without creating a separate object file.