CS-5300 Practice Chapter 1

Every compiler converts a(n) ___ program to a(n) ___ program.
Programming language, executable language
source, target
Text, binary
What type of compilers do many Java interpreters use?
Clocked
Translating
Just-in-time
What do macros get converted into?
Target language statements
Optimized constructors
Source language statements
What does the assembler do?
Converts assembly code into machine code.
Collects the different files of the source code together.
Resolves external memory addresses.
What are the two main parts of a compiler?
Latent and realtime
Analysis and synthesis
Classifier and constructor
Symbolic and semantic
The analysis part of the compiler passes what two things on to the synthesis part?
Symbol representation and semantic table
Binary representation and structure table
Intermediate representation and symbol table
The synthesis part of a compiler is also called the
Back end.
Construction.
Core.
Target.
The symbol table is
Not really a table.
Used by all phases of the compiler.
Constructed by the synthesis part of the compiler.
Exponential in size.
Another name for scanning is
Searching.
Read-interpreting.
Lexical analysis.
In the lexical analyzer example in the book, what are the token names?
Position, initial, rate, 60, =, +, *
1, 2, 3, null
id, 60, =, +, *
Another name for parsing is
Syntax analysis.
Tree construction.
Semantic construction.
In a syntax tree an interior node represents
An argument.
A procedure.
An operation.
In the example in sections 1.2.1 and 1.2.2, what does <id, 3> represent?
Position
Rate
Syntax
In what stage is the syntax tree built?
Syntax analysis
Lexical analysis
Semantic analysis
In what stage does type checking occur?
Lexical analysis
Syntax analysis
Semantic analysis
The example on coercion uses
A boolean and a float.
A boolean and an integer.
An integer and a float.
Which is not an example of an intermediate representation?
Three-address code
Syntax tree
Symbol table
Which is not a reason given in the book to optimize code?
Target code that consumes less power
Faster target code
Readable target code
Shorter target code
Where are variable and procedure names stored?
Syntax tree
Registers
Symbol table
How can we support multiple target machines for a single source language?
Multiple passes for the front end
Multiple passes for the back end
Multiple front ends
Multiple back ends
In a generation classification of programming languages, Java is what?
Fourth-generation
Second-generation
First-generation
Third-generation
The problem of generating the optimal target code from a source program is
Quadratic.
Undecidable.
O(n).
Nearly solved.
Of the four design objectives of compiler optimizations, which is the most important?
Performance improvement
Engineering effort
Compile time
Correctness
What do finite-state machines and regular expressions model?
Keywords and identifiers
Optimal register allocation
Semantic constructs
What early feature of the C programming language was useful early on but actually could result in inefficient code if used today?
Structs
Bit packing
The register keyword
The boolean type
What compiler optimizations analyze the flow of data through a program?
Control-structure optimizations
Data-flow optimizations
Control-flow optimizations
Java has many features listed in the reading that make programming easier. What is true about all of them?
They guarantee against out-of-bounds errors.
They incur run-time overhead.
They also simplify many aspects of the back-end of the compiler.
What can be found in most computers both at the instruction level and at the processor level?
Pipelining
Parallelism
Stream allocation
According to the book, what is probably the single most important problem in optimizing a program?
Supporting different architectures
Using registers effectively
Instruction parallelism
In the old days, compilers were developed _______ computer architecture design.
During
After
Before
The x86 processor
Has a CISC instruction set but it is most effective when only its simple instructions are used.
Has a RISC instruction set but it is most effective when only its simple instructions are used.
Has a CISC instruction set, which is best utilized when it's more sophisticated instructions are used.
What did Apple use to allow software written for the Motorola MC 68040 processor to run on the PowerPC?
Binary translation
Virtual machines
Compatible instruction sets
Static error checkers using data flow analysis are different from optimizers in what respect? Choose the best answer.
Optimizers never get it wrong.
Error checkers are sound.
Optimizers happen after runtime.
Bounds checking
Is best done using a compiler-independent runtime tool.
Protects against buffer overflow attacks.
Is used in the C programming language.
static in a Java class declaration means the variable will be stored in memory
Temporarily.
With the class declaration.
With each object instantiation.
What maps names to locations (variables) in memory (the store)?
Location dictionary
State
Environment
What maps memory locations to values?
Value dictionary
Environment
State
A procedure
Does not return a value.
Always returns a value.
Is the same as a function.
In C, a top-level variable is in scope everywhere in the program following the declaration except
In functions with an identically-named variable.
In polymorphic classes.
In functions that are static.
What is block structure?
Structs and classes being defined using blocks
Data hiding in structs by restricting access
Nesting blocks inside of other blocks

In figure 1.10, what is the scope of declaration of the following code?

int b=1;

B1
B1-B2
B1 and B3
B1 and B4
In figure 1.10, what are the surrounding blocks of variables a and b used in block B4?
B2, B1
B4
B4, B2, B1
All 4 blocks
An example of dynamic scoping is
Polymorphic procedures.
Block structure.
User input scenarios.
Which is true?
Actual parameters are known at compile time.
Actual parameters are associated with formal parameters.
Formal parameters are the parameter values.
Java uses
A logistic symbol table.
Pointer arithmetic.
Call-by-value.
When would someone use the ref keyword in C++?
When desiring dynamic scope
When passing a large object to a function
When copying an array
Calling a C++ function f(ref x, ref x) is an example of
Aliasing.
Polymorphism.
Pass-by-value.
{"name":"CS-5300 Practice Chapter 1", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Every compiler converts a(n) ___ program to a(n) ___ program., What type of compilers do many Java interpreters use?, What do macros get converted into?","img":"https://www.quiz-maker.com/3012/CDN/89-4309114/figure-1-10.png?sz=1200"}
Powered by: Quiz Maker