Language Design & Implementation
Using composition, objects share a __________ relationship with other objects.
"has a"
Which of the Scheme expressions forms the list of 1 and 2? (Select all that apply.)
'(1 2) (list 1 2) (cons 1 (cons 2 '())
Which of these mathematical expressions uses prefix notation? (Select all that apply.)
(+ 1 3) (* 5 (+ 3 4))
The following regular expressions will find any instance of cat or dog within a large body of text. (Select all that apply.)
(cat|dog) (dog|cat)
Which of the Scheme expressions forms the pair of 1 and 2? (Select all that apply.)
(cons 1 2) '(1 . 2)
Which of the following expressions are in fully parenthesized Polish notation? (Select all that apply.)
(equal? 1 2) (+ 1 2)
A typical compiler has how many phases or stages?
3
What does the term iteration mean?
A control statement that allows the program to repeat a sequence of instructions until the program reaches a specific state.
What is a pointer?
A data type that stores an address in memory.
What does the term duck typing refer to?
A form of dynamic typing that allows a program to handle data based on the characters used to define the data, without the need for an explicit data type definition.
Which of the following statements best describes the difference between a function and a procedure?
A function returns data but a procedure does not.
What is a function?
A group of code that alters only a small part of a program and that can be reused within a program.
What is a mixin?
A module of code that can be embedded inside multiple classes to streamline functionality.
Which of the following definitions best describes a function?
A statement that accepts input, operates on the inputs, and returns an output.
Just-in-time compilation is the process of:
A technique in which parts of an interpreted program are actually compiled to a lower level language at run time.
What are the basic requirements of an imperative programming language? (Choose all that apply.)
Ability to change program state Guaranteed execution of instructions in a sequential order
What data structure is commonly used to represent a program internally in a compiler?
Abstract syntax tree
Interpreting a programming language can happen: (Select all that apply)
After compilation into an intermediate language In real time from the AST generated.
The output of parsing is:
An abstract syntax tree
The output of lexical analysis is:
An array of tokens
Which of the following are advantages of modular programming? (Select all that apply.)
Bugs are scoped to modules of code Code reuse
The type of hardware architecture impacts which of the following? (Select all that apply.)
Compiler Standard library
What other concept can be used instead of Inheritance to abstract away data and functionality?
Composition
What are the basic requirements of a structured program? (Choose all that apply.)
Control statements Imperative in nature Functions and procedures
Which of the following are techniques can a programmer use to implement an algorithm expressively? (Select all that apply.)
DSLs Generic programming
In reference to programming languages, what does the acronym DSL refer to?
Domain specific language
Which of the following are pillars of object-oriented programming and design (select all that apply)?
Encapsulation Inheritance Polymorphism
True or False: Garbage collection improves program performance.
FALSE
True or False: In an abstract syntax tree, every character in the programming language appears as a node in the tree.
FALSE
True or false: An EBNF is a required component for documentation of a programming language.
FALSE
True or false: Every program in every programming language generates the same basic Abstract Syntax Tree structure.
FALSE
True or false: Tokens are individual characters in the source code.
FALSE
True or false? A programming language can be both statically and dynamically typed.
FALSE
True or false? Declarative programming languages focus on how to solve a problem rather than what the solution should look like.
FALSE
True or false? Immutable data will change their value within the scope of a function.
FALSE
True or false? Regular expressions are useful for mathematical calculations
FALSE
True or false? The programming language C manages all memory for the developer.
FALSE
Which computation model is useful for building a regular expression engine?
Finite-state machine
What does the term context refer to in a programming language?
How a programming language will interpret a specific symbol or character in a specific setting within a program.
Which of the following should a developer consider before adopting a programming language? (Select all that apply.)
How widely-used the language is by other developers The length of time a language has existed The amount of community support available
If the DSL syntax is valid syntax for the host programming language, it is an ________ DSL.
Internal
Which of the following statements are tenets of simple design? (Select all that apply.)
It runs all the tests. It states every intention important to the programmers. It has the fewest possible classes and methods.
What does a goto statement do?
It tells the program to skip to another line of code when a condition is met instead of executing the next line of code.
During lexical analysis, a __________ reads through the source code, line by line.
Lexer
What describes the following statement: In the first phase of compilation, the compiler will read in the source code and convert characters into meaningful tokens.
Lexical analysis
Which of the following statements best describes the difference between low-level languages and high-level languages?
Low-level languages are closer to machine language while high-level languages are closer to human language.
Which of the following statements about an external DSL are true? (Select all that apply.)
Many programming languages can use an external DSL. An external DSL is typically human-readable. A host language must typically translate the external DSL to understand it.
What is the term for the process by which a program asks the operating system for memory?
Memory allocation
What are the basic requirements of a procedural program? (Choose all that apply.)
Modularized code Structured in nature
What does the term bitwise refer to?
Operations that take place on bits of data.
Which of the following terms refers to the first phase of compilation, where the compiler takes in a series of tokens and generates an Abstract Syntax Tree.
Parsing
A fluent interface places this as the highest priority:
Readability
Which of the following statements is the best definition of phrases in a programming language?
Rules of how tokens, symbols, characters, and whitespace can be used in the programming language.
Which of the following are examples of control structures? (Select all that apply.)
Sequence Selection Iteration
What is a programming language comprised of? (Select all that apply.)
Standard library Syntax Semantics
Which type of system prefers to define the data types upfront for compilation?
Statically typed
True or False: High-level and low-level languages can be modular programming languages.
TRUE
True or False: Object-oriented programming languages can also be modular programming languages.
TRUE
True or False: Prefix notation does not require parentheses for evaluation.
TRUE
True or false: A variable can be a reference to a value or function within a programming language.
TRUE
True or false: Compiled programming languages are more efficient.
TRUE
True or false? Assembly is an example of a low-level language.
TRUE
True or false? Functions are high-order if they accept and return functions.
TRUE
True or false? Procedural programming languages are imperative programming languages.
TRUE
True or false? Scheme is a Lisp.
TRUE
True or false? Structured programming languages are imperative programming languages.
TRUE
True or false? The programming language C has the goto statement.
TRUE
True or false? This function is tail recursive.
TRUE
The definition of source-to-source compilation is:
Taking source code from one programming language and outputting the same logical program in another programming language
The benefits of a DSL are (select all that apply):
The DSL increases readability and intention of the code. The DSL uses natural words that are common to the domain. Domain experts can easily communicate the DSL.
Which of the following statements is an example of semantics?
The assent that a "+" symbol means "to add."
Which of the following statements is the best definition of syntax?
The combination of tokens, phrases, and context that create a formal programming language.
A context-free grammar defined by an EBNF shows which quality?
The definition of each rule follows from the previous set of rules.
External DSLs require:
The host programming language to parse and evaluate the DSL.
What is the role of a parser?
The parser maps tokens into an abstract syntax tree during compilation.
What does the term scope mean in programming languages?
The scope is the section of statements in which a variable or function can be used by name and has value.
Which of the following statements is the best definition of tokens in a programming language?
The set of valid symbols and characters in a programming language.
A lexer can also be called a/an _____________. (Select all that apply.)
Tokenizer
One common technique for parsing a set of tokens is to use a:
Top-down approach
Transcompilation is the process of:
Translating the AST into another language and invoking its compiler.
Which of the regular expressions below would map to the finite state machine shown below?
[0-9]+%
Which of the following regular expressions will find any reference to a zip code (five-digit or five-digit with four-digit extension) within a large body of text? (Select all that apply.)
[0-9]{5}(-[0-9]{4})?[^-0-9]
Which of the following regular expressions will find any reference to a price within a large body of text? Note: A price must consist of a dollar sign ($), digits, and a decimal point (ignore commas). (Select all that apply.)
\$\d{1,}\.\d{2} \$\d+\.\d{2} \$[0-9]+\.[0-9][0-9]
Which of the Scheme expressions forms the list (1 (2 3) 4)? (Select all that apply.)
`(1 (2 3) 4) (list 1 (list 2 3) 4) (cons 1 (cons (cons 2 (cons 3 '())) (cons 4 '())))
Which initialization statement creates an array of integers? (Select all that apply.)
int myIntegers[]; int * myIntegers; char * myIntegers;
Which line in Fortran 90 instantiates an array of integers with a length of 6?
integer, dimension(0:5) :: myIntArray
Which of the following terms can apply to modules in different programming languages? (Select all that apply.)
package namespace
Which of the following terms is a synonym for argument in a function or procedure?
parameter
Which initialization statement defines a real number constant called pi in Fortran?
real, parameter :: pi = 3.141592653589793
What is the term for the user-defined type that composes other data types?
struct