4337 Programming Languages (quiz 1-4) Exam 1
(setf line '(roses are red)) What is the result of the following expression? (cons (last line) line)
((red) roses are red)
What is CADR of the following expression? ((BLUE CUBE) (RED PYRAMID))
(RED PYRAMID
What is the result of: (list 'cons t nil)
(cons t nil)
What is Lisp lambda function to subtract 7 from a number (a parameter n)?
(lambda (n) (- n 7))
What is the result of: (mapcar #'zerop '(2 0 -5))
(nil t nil)
Given (setf line '(roses are red)) What is the result of: (reverse line)
(red are roses)
Given the following Lisp statement run (setf line '(roses are red)) What is the result of the following statement? (list (first line) (last line))
(roses (red))
What is the result of the following expression? (apply #'cons '(t nil))
(t)
What is the result of the following Lisp function? (length '((OPEN) (THE POD BAY DOORS) HAL))
3
In a(n) ____, the programmer uses a programming language (in context free grammar) to tell the computer what to accomplish and how to do it.
3GL
What is the result of the following Lisp function? (length '((ONE) FOR ALL (AND (TWO (FOR ME)))))
4
What is the result of the following Lisp function? (length '(1 2 3 4))
4
What is the result of the following expresion? (+ 1 2 3)
6
What is the result of the following expression? (+ (- 5 2) 3)
6
The following grammar is ambiguous. <expr> → <expr> <op> <expr> | const <op> → * | + Which one of the following grammar is equivalent to this grammar but not ambiguous?
<expr> → <expr> + <term> | <term> <term> → <term> * const | const
Which one of the following statements is NOT correct? For an attribute grammar, ___
An attribute can be inherited but not synthesized.
The first widely used programming language developed for the applications was the functional language LISP (McCarthy et al., 1965), which appeared in 1959. Most AI applications developed prior to 1990 were written in LISP or one of its close relatives. During the early 1970s, however, an alternative approach to some of these applications appeared—logic programming using the Prolog language. This is an example of ____.
Artificial Intelligence or Programming Language(s)
This domain is a broad area of computer applications characterized by the use of symbolic rather than numeric computations. Symbolic computation means that symbols, consisting of names rather than numbers, are manipulated. Also, symbolic computation is more conveniently done with linked lists of data rather than arrays. This kind of programming sometimes requires more flexibility than other programming domains. For example, in some applications the ability to create and execute code segments during execution is convenient. This is an example of ____.
Artificial Intelligence or Programming Language(s)
_____ is equivalent to context-free grammars developed by John Backus
BNF
_____ is invented to describe the syntax of Algol 58
BNF
In learning the concepts of programming languages, it is both interesting and necessary to touch on the implementation issues that affect those concepts. In some cases, an understanding of implementation issues leads to an understanding of why languages are designed the way they are. In turn, this knowledge leads to the ability to use a language more intelligently, as it was designed to be used. We can become better programmers by understanding the choices among programming language constructs and the consequences of those choices. This is an example of ____.
Better understanding of the significance of implementation.
[Sebesta01] According to the author. Consider the list of potential benefits of studying concepts of programming languages. One of the benefits would be argued as follows: In learning the concepts of programming languages, it is both interesting and necessary to touch on the implementation issues that affect those concepts. In some cases, an understanding of implementation issues leads to an understanding of why languages are designed the way they are. In turn, this knowledge leads to the ability to use a language more intelligently, as it was designed to be used. We can become better programmers by understanding the choices among programming language constructs and the consequences of those choices. This is an example of ____.
Better understanding of the significance of implementation.
___ was developed as a systems programming language for the development of UNIX.
C
___ contain the formats (style) for how a particular object should display in a Web browser.
Cascading style sheets (CSS)
The major commercial language for the period 1960 through the 1990s was ____.
Cobol
One of the complicating characteristic of a programming language is ____- that is, having more than one way to accomplish a particular operation.
Feature multiplicity
One of the complicating characteristics of a programming language is ____- that is, having more than one way to accomplish a particular operation.
Feature multiplicity
John Backus was instrumental in the development of the first 3rd generation programming language called ____
Fortran
Many professional programmers have had little formal education in computer science; rather, they have developed their programming skills independently or through in- house training programs. Such training programs often limit instruction to one or two languages that are directly relevant to the current projects of the organization. Many other programmers received their formal training years ago. The languages they learned then are no longer used, and many features now available in programming languages were not widely known at the time. The result is that many programmers, when given a choice of languages for a new project, use the language with which they are most familiar, even if it is poorly suited for the project at hand. If these programmers were familiar with a wider range of languages and language constructs, they would be better able to choose the language with the features that best address the problem. This is an example of ____.
Improved background for choosing appropriate languages.
Computer programming is still a relatively young discipline, and design methodologies, software development tools, and programming languages are still in a state of continuous evolution. This makes software development an exciting profession, but it also means that continuous learning is essential. The process of learning a new programming language can be lengthy and difficult, especially for someone who is comfortable with only one or two languages and has never examined programming language concepts in general. Once a thorough understanding of the fundamental concepts of languages is acquired, it becomes far easier to see how these concepts are incorporated into the design of the language being learned. For example, programmers who understand the concepts of object-oriented programming will have a much easier time learning Java (Arnold et al., 2006) than those who have never used those concepts. This is an example of ____.
Increased ability to learn new languages.
____ is a set of technologies by Sun/Oracle that allows programmers to develop and deploy Web services for a company.
Java EE
A(n) ____ is a compiled program that runs on the client.
Java applet
One of the Functional programming languages is _______
LISP
The major AI language for the period 1960 through the 1990s was ______.
LISP
Leftmost derivation is used in ____ parsing.
LL
A(n) ____ is a set of sentences
Language
A(n) _____ is the lowest level syntactic unit of a language (e.g., +, *, 123, ...)
Lexeme
Context-Free Grammars is developed by ____ in the mid-1950s.
Noam Chomsky
One of the potential problems is _____, in which a single operator symbol has more than one meaning. Although this is often useful, it can lead to reduced readability if users are allowed to create their own overloading and do not do it sensibly.
Operator overloading
This ______ feature or criteria is about a relatively small set of primitive constructs which can be combined in a relatively small number of ways, and every possible combination is legal.
Orthogonality
______ is the most popular server-side programming language
PHP
One of the logic programming languages is ______
Prolog
One application of XML is the _____ specification, often used by news Web sites to publish headlines and stories.
RSS 2.0
In the 1970s, the software life-cycle concept (Booch, 1987) was developed; coding was relegated to a much smaller role, and maintenance was recognized as a major part of the cycle, particularly in terms of cost. The ease of maintenance is determined in large part by the ____ of programs. This became an important measure of the quality of programs and programming languages.
Readability
___ is the evaluation criteria for the ease with which programs can be understood
Readability
"Data Type" is primarily important for the following criterion or criteria: _____
Readability, Writability, Reliability
According to the author. Consider the list of some important criteria of a programming language. Select the best answer. Syntax Design is primarily concerned for this criterion (or criteria).
Readability, Writability, Reliability
Data Type is primarily concerned for this criterion (or criteria).
Readability, Writability, Reliability
Orthogonality is primarily concerned for this criterion (or criteria).
Readability, Writability, Reliability
Simplicity is primarily concerned for this criterion (or criteria).
Readability, Writability, Reliability
Exception Handling is primarily concerned for this criterion (or criteria).
Reliability
Restricted Aliasing is primarily concerned for this criterion (or criteria).
Reliability
Type Checking is primarily concerned for this criterion (or criteria).
Reliability
is for the evaluation criteria for the conformance to specifications (i.e., performs to its specifications).
Reliability
The early high-level programming languages invented for _____ applications were designed to provide for those needs. Their competition was assembly language, so efficiency was a primary concern. The first language for scientific applications was Fortran. For some applications where efficiency is the primary concern, such as those that were common in the 1950s and 1960s, no subsequent language is significantly better than Fortran, which explains why Fortran is still used. This is an example of ____.
Scientific Applications or Programming Language(s)
A(n) ____ is a sentential form that has only terminal symbols
Sentence
A(n) _____ is a string of characters over some alphabet
Sentence
The UNIX operating system is written almost entirely in C, which has made it relatively easy to port, or move, to different machines. Some of the characteristics of C make it a good choice for this programming domain. It is low level, execution efficient, and does not burden the user with many safety restrictions. This is an example of ____.
Systems Programming or Programming Language(s)
This type of software is used almost continuously and so it must be efficient. Furthermore, it must have low-level features that allow the software interfaces to external devices to be written. For IBM mainframe computers, the language was PL/S, a dialect of PL/I. This is an example of ____.
Systems Programming or Programming Language(s)
A(n) _____ is a category of lexemes (e.g., identifier)
Token
A(n) _____ programming language is a language that uses a graphical interface for creating all source code.
Visual
The World Wide Web is supported by an eclectic collection of languages, ranging from markup languages, such as HTML, which is not a programming language, to general-purpose programming languages, such as Java. Because of the pervasive need for dynamic Web content, some computation capability is often included in the technology of content presentation. This functionality can be provided by embedding programming code in an HTML document. Such code is often in the form of a scripting language, such as JavaScript or PHP. There are also some markup-like languages that have been extended to include constructs that control document processing. This is an example of ____.
Web Software or Programming Language(s)
_____ is for the evaluation criteria for the ease with which a language can be used to create programs
Writability
Expressivity is primarily concerned for this criterion (or criteria).
Writability, Reliability
Support for Abstraction is primarily concerned for this criterion (or criteria).
Writability, Reliability
A grammar is ____ if and only if it generates a sentential form that has two or more distinct parse trees
ambiguous
The following expr grammar is ____. <expr> → <expr> + <expr> | const
ambiguous
Given the following statement: (setf line '(roses are red)) What is the result of: (nth 1 line)
are
_____ is a logic expression in Axiomatic Semantics
assertion
The following grammar is an example of _____. <var>[1].actual_type ← lookup (A) <var>[2].actual_type ← lookup (B) <var>[1].actual_type =? <var>[2].actual_type
attribute grammar
____ semantics is based on formal logic (predicate calculus)
axiomatic
Compute the weakest precondition for each of the following assignment statement and postcondition: a = 2 * (b - 1) - 1 {a > 0}
b > 3 / 2
Compute the weakest precondition for each of the following assignment statement and postcondition: b = (c + 10) / 3 {b > 6}
c > 8
A program has its own inline documentation, called ____
comments
_____ is the semantics originally developed by Scott and Strachey (1970)
denotational
_____ semantics is the semantics based on recursive function theory
denotational
The meaning of language constructs are defined by only the values of the program's variables. That is, the state of a program is the values of all its current variables.
denotational semantics
Which one of the following choices is CORRECT? β is the ___ of the right sentential form γ=αβw if and only if S =>*rm α A w =>rm α β w.
handle
{I} is a(n) _____ in the following rule in a while-statement in axiomatic semantics: {I} while B do S {I and (not B)}
loop invariant
What is the result of the following expression: (eql 3 3.0)
nil
What is the result of the following expression? (eval (list 'eval nil))
nil
What is the result of the following expression? (eval nil)
nil
In BNF, a rule has a left-hand side (LHS), which is/are _____
nonterminal
The "disassemble" Lisp function provides an ____ semantics of a program.
operational
The change in the state of the machine (memory, registers, etc.) defines the meaning of the statement.
operational semantics
____ describes the meaning of a program by executing its statements on a machine, either simulated or actual.
operational semantics
A(n) ____ is an interpreted program that runs on the server.
php script
Which one of the following choices is CORRECT? β is a(n) ___ of the right sentential form γ if and only if S =>* γ = α1 A α2 =>+ α1 β α2
phrase
_____ is an assertion following a statement which states the relationships and constraints among variables that are true after that point in execution
postcondition
_____ is an assertion before a statement stating the relationships and constraints among variables that are true at that point in execution
precondition
Given (setf line '(roses are red)) What is the result of: (first (last line))
red
Which one of the following statements is CORRECT? For bottom-up parsing, the parsing problem is finding the correct RHS in a(n) ____ form to reduce to get the previous ____ form in the derivation
right-sentential
_____ is the meaning of the expressions, statements, and program units.
semantics
_____ form is the string of symbols (nonterminals and terminals) in a derivation
sentential
Which one of the following choices is CORRECT? β is a(n) _____ of the right sentential form γ if and only if S =>* γ = α1 A α2 => α1 β α2
simple phrase
What is the result of the following expression: (equal '(a b) '(a b))
t
_____ is lexeme or token, and shows only in right-hand side of a grammar rule.
terminal
_____ is the least restrictive precondition that will guarantee the postcondition.
weakest precondition