Download revision sheet

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Antisymmetry wikipedia , lookup

Transformational grammar wikipedia , lookup

Agglutination wikipedia , lookup

Junction Grammar wikipedia , lookup

Parsing wikipedia , lookup

Transcript
1. Which of the
following are
tokens in
Java?
identifier
mult_op
}
while
2.
Which of the following are lexemes in Java?
++
for
int_literal
semicolon
3.
Context-free grammars were devised by
Noam Chomsky
Peter Naur
John Backus
John McCarthy
4.
Which of the following are nonterminal symbols in the grammar
rule:
<factor> -> (++ | --) ident | (+ | -) (ident | int_literal) | (<expr>)
+
<expr>
<factor>
ident
5.
Which of the following are terminal symbols in the grammar rule:
<factor> -> (++ | --) ident | (+ | -) (ident | int_literal) | (<expr>)
ident
int_literal
<expr>
++
6.
A grammar is ambiguous if it:
Has two rules that have the same RHSs
Has ε rules
Produces a sentential form that has two distinct parse trees
Has a rule with more than four RHSs
Which of the following is not a kind of attribute in an attribute
grammar?
Intrinsic
7.
Synthesized
Free
Inherited
Which of the following need not be true for a loop invariant?
P => I
8.
I => Q
{I and (not B)} => Q
{I and B} S {I}
Which of the following sentences cannot be derived using the
grammar of Example 3.2?
A = C * (A * C + B)
9.
A = A * (B + (C * A))
A = A + (B + C)
A = A * (B + ( C ))
Which of the following
is not a reason to
separate lexical
analysis from syntax
analysis?
Simplicity
Readability
Efficiency
Portability
2.
Why are reserved words not recognized
through state transitions in a lexical
analyzer?
The number of reserved words may
change as the language evolves
Their structure is nearly the same as
that of identifiers
Reserved words are inherently
difficult to recognize using that
approach
That would required a very large state
diagram
3.
What kind of derivation is produced by topdown parsers?
Neither leftmost nor rightmost
Rightmost
Leftmost
Reverse of a rightmost
4.
What kind of derivation is produced by
bottom-up parsers?
Leftmost
Rightmost
Neither leftmost nor rightmost
Reverse of a rightmost
5.
To be useful, a parsing algorithm must
have complexity no greater than
O(n3)
O(n2)
O(n)
NP complete
6.
The purpose of the pairwise disjointness
test is to
Determine whether a grammar is
ambiguous
Determine whether a grammar is
parsable by any method
Determine whether a grammar is topdown parsable
Determine whether a grammar is
bottom-up parsable
7.
The purpose of left factoring is
To convert a grammar into one that is
top-down parsable
To convert a grammar into one that is
unambiguous
To convert a grammar into one that is
parsable by any method
To convert a grammar into one that is
bottom-up parsable
8.
A simple phrase is
A phrase that includes no nonterminal
symbols
A phrase that includes no terminal
symbols
A phrase that is generated in one
derivation step
A phrase that includes no more than
two symbols
9.
Which of the following is not an advantage
of LR parsers?
They will work for nearly all grammars
that describe programming languages
The LR class of grammars is a
superset of the class parsable by LL
parsers
They are very easy to construct by
hand
They can detect syntax errors as
soon as it is possible
10 .
Left recursion in a grammar is a problem
for
Only recursive descent parsers
All top-down parsers
All bottom-up parsers
All parsers
11 .
Which of the following are not goals of a
syntax analyzer?
Determine whether a given string is a
sentence in the language
To produce a parse tree or a trace of
a parse tree
To recognize the identifiers in a
program
To ensure that the numeric literals in
a program are syntactically correct
12 .
Parsers are based on which of the
following mathematical machines?
Deterministic finite automata
Nondeterministic finite automata
Turing machines
Pushdown automata
13 .
Which two of the following prevent a
grammar from being top-down parsable?
Having two RHSs of the same
nonterminal that begin with the same
string
Having ε rules
Having left recursive rules
Having right recursive rules
Which of the
following are
primary design
issues for names?
Can names
end in digits?
Are names
case
sensitive?
Are the
special words
reserved
words or
keywords?
Can names
begin with
uppercase
letters?
2.
Which of the following
languages have case-sensitive
names?
C++
Fortran
C#
COBOL
3.
Which of the following language
evaluation criteria is/are violated
by having case-sensitive
names?
Readability
Writability
Reliability
Cost
4.
Aliases can be created by which
of the following language
constructs?
The union types of C and
C++
Assignment statements
Pointer assignments
Whole array operators
5.
Which of the following
languages have implicit type
declarations?
Java
Fortran
C
Perl
6.
Which of the following
languages use dynamic type
binding?
C++
Perl
PHP
JavaScript
7.
After language design and
implementation, which of the
following is not a time when
bindings can take place?
At run time
At compile time
At link time
At the end of the execution
of a subprogram
8.
Which of the following is not a
category of scalar variables
defined by the their lifetimes?
Static
Stack dynamic
Explicit stack dynamic
Explicit heap dynamic
9.
Which of the following
languages are nearly strongly
typed?
C++
C#
Fortran 95
Ada
10 .
Which of the following
languages use dynamic
scoping?
C++
Perl
C#
APL
11 .
Which of the following is not a
problem with dynamic scoping?
Reliability
Static type checking is not
possible
Array element access is
slower
Readability
12 .
Which of the following
languages does not allow
dynamic binding of values to
named constants?
Ada
C++
Fortran 95
Java
1.
Which of the following is not a primitive
data type?
Boolean
Integer
Floating point
A single-dimensional array of integers
2.
Which of the following are disadvantages
of decimal types?
Their representation in memory is
wasteful
They can represent quantities of
money exactly
The decimal point must be implied
Their range of values is restricted
3.
Which of the following is not used in a
contemporary programming language for
character strings?
ISO 8859-1
BCD
ASCII
Unicode
4.
Which of the following are not design
issues for character strings?
Should strings have static or dynamic
length?
Should strings be simply a special
kind of character array or a primitive
type?
Should strings be limited to no more
than 100 characters?
Should strings be stored in linked
lists?
5.
Which of the following languages does not
have pattern matching built in to the
language?
PHP
Java
Perl
JavaScript
6.
Which of the following is not a string
length option for character string types?
Dynamic length
Static length
All strings are of a single fixed length
Limited dynamic length
7.
Which of the following is not a primary
design issue for enumeration types?
Are any other types coerced to an
enumeration type?
Is an enumeration constant allowed
to appear in more than one type
definition, and if so, how is the type of
an occurrence of that constant in the
program checked?
Are enumeration values coerced to
integer?
Are enumeration values represented
internally as integer values?
8.
Which of the following languages allows
overloaded literals?
C++
Ada
Java
C#
9.
Which of the following is not a primary
design issue for arrays?
What types are legal for subscripts?
What is the maximum length of a
single-dimensional array?
What kinds of slices are allowed, if
any?
When does array allocation take
place?
10 .
Which of the following languages do not
specify array index range checking?
C#
Java
Perl
C++
11 .
Which of the following is not a category of
arrays determined by binding to subscript
ranges and bindings to storage?
Fixed heap-dynamic
Static
Dynamic
Fixed stack-dynamic
Which of the following
is not a primary design
issue for arithmetic
expressions?
Should array
elements be
allowed to be
operands?
What is the order
of operand
evaluation?
What are the
operator
associativity
rules?
Does the
language allow
user-defined
operator
overloading?
2.
The semantics of an
arithmetic expression are
determined by which of
the following?
Operator
associativity
The number of
different integer
data types in the
language
Whether the
language includes
pointers or
references or both
Operator
precedence
3.
Which of the following
operators is usually right
associative?
Unary +
Binary +
++
*
4.
Which of the following
operations can cause a
functional side effect?
Change of a twoway parameter
Addition
Change in a global
variable
Conditional
expressions
5.
Which of the following
statements are true?
User-defined
operator
overloading can aid
readability
A narrowing
conversion is
always safe
A widening
conversion is
always safe
User-defined
operator
overloading can be
detrimental to
readability
6.
Which of the following
languages uses the
fewest number of
coercions in arithmetic
expressions?
Ada
C
Java
C++
7.
Which of the following
languages always does
short-circuit evaluation of
Boolean expressions?
Java
C++
C
Ada
8.
Which of the following
languages allow
conditional targets on
assignment statements?
Ada
C
C#
Java
Which of the following
is not a primary design
issue for two-way
selectors?
Is the else clause
optional, or is it
required?
How are the then
and else clauses
specified?
What is the form
and type of the
expression that
controls the
selection?
How should the
meaning of
nested selectors
be specified?
2.
Which of the following languages does
not use a static semantics rule to specify
the if construct to which an else clause
belongs when the clause follows a
nested if?
Ada
C++
Perl
Java
3.
Which of the following is not a design
issue for multiple selection statements?
What is the form and type of the
expression that controls the
selection?
How should unrepresented selector
expression values be handled, if at
all?
Is execution flow through the
structure restricted to include just a
single selectable segment?
What is the maximum number of
selections that can be included in
the construct?
4.
Which of the following languages has a
switch statement that has different static
semantic rules that those of the others?
C
Java
C++
C#
5.
Which of the following is not a primary
design issue for counter-controlled
loops?
Should the loop parameters be
evaluated only once, or once for
every iteration?
What is the maximum depth to
which counter-controlled loops can
be nested?
What value does the loop variable
have at loop termination?
What are the type and scope of the
loop variable?
6.
Which of the following languages does
not have a counter-controlled loop
statement that uses the for special
word?
Ada
Fortran 95
C#
Java
Which of the following languages require
the control expression of its countercontrolled looping statement to be of
boolean type?
C#
7.
Java
C++
C
Which of the following languages have a
predefined loop statement that is
controlled by a data structure?
C#
8.
C++
Java
Perl
Which of the following languages has a
goto statement?
Java
9.
Ada
C#
C
The following defines which of the
following terms? A blank of a
subprogram is the number, order, and
types of its formal parameters.
Protocol
Subprogram call
Parameter profile
Subprogram prototype
2.
Which of the following
languages does not require
that the number of actual
parameters match the
number of formal
parameters?
JavaScript
C++
Fortran 95
Perl
3.
Which of the following is not a
primary design issue for
subprograms?
Are local variables
statically or dynamically
allocated?
Can subprograms be
recursively called?
Can subprograms be
overloaded?
What parameter-passing
method or methods are
used?
4.
Which of the following is not a
disadvantage of stackdynamic locals in
subprograms?
Subprograms can be
recursive
The cost of allocation,
initialization, and
deallocation
Subprograms cannot be
history sensitive
Accesses must be
indirect
5.
Which of the following
languages allows a user to
specify whether a
subprogram will be
recursively called?
C++
Fortran 95
Ada
C#
6.
Which of the following is not a
semantics model for
parameter passing?
In mode
Inout mode
Out mode
Pass by reference
7.
Which of the following
support only one-way
parameter passing?
Pass by reference
Pass by value
Pass by value result
Pass by result
8.
Which of the following
languages supports two-way
parameters (not counting
passing pointers or
references)?
Fortran 95
C#
Java
Ada
9.
Which of the following
languages do not require
parameter type checking?
C#
Fortran 95
Perl
PHP
10 .
In which of the following
languages are all arrays
objects?
Java
C
C#
Fortran 95
11 .
Which of the following is not a
choice for the binding of a
passed subprogram to its
correct referencing
environment?
Deep binding
Ad hoc binding
Shallow binding
Backwards binding
12 .
In which of the following
languages can users define
overloaded subprograms?
Ada
C++
C#
C
13 .
The generic subprograms of
Ada are an example of which
of the following forms of
polymorphism?
Overloaded method
polymorphism
Parametric
polymorphism
Ad hoc polymorphism
Forward polymorphism
14 .
Which of the following
languages support generic
subprograms?
Java
C#
C++
Ada
15 .
Which of the following is a
design issue for functions?
Are side effects
allowed?
What types of values
can be returned?
What is the maximum
number of parameters?
Are functions required to
return values?
16 .
Which of the following
languages support userdefined overloaded
operators?
Java
C++
Ada
C
Which of the following
subprogram characteristics
is/are violated by coroutines?
Every subprogram has a
single entry point
Control always returns to
the caller when the
subprogram execution
terminates
The calling program unit
is suspended during the
execution of the called
subprogram
17 .
A static link points to
Another static
link in some
activation record
instance on the
runtime stack
The bottom of
the activation
record instance
of the calling
program unit
The top of the
activation record
instance of an
activation of the
static parent
The bottom of
the activation
record instance
of an activation
of the static
parent
2.
A dynamic link points to
The bottom of the activation
record instance of an
activation of the static parent
Another dynamic link in
some activation record
instance on the runtime
stack
The bottom of the activation
record instance of the calling
program unit
The top of the activation
record instance of the calling
program unit
3.
Nesting depth is the same as
Static offset
Chain offset
Static chain
Static depth
4.
In a static scoped language that
uses static chaining as an
implementation technique,
references to non-local variables
can be represented as
Static depth/Local offset
Chain offset/Local offset
Static chain length/Local
offset
Chain offset/Static depth
5.
Which of the following are the two
ways dynamic scoping can be
implemented?
Deep binding
Deep access
Shallow binding
Shallow access
6.
A display is
A window that displays the
output of a debugger
A display of all of the static
scopes of a program
A stack of the static links in a
program execution
A stack of the dynamic links
in a program execution
7.
Which of the following are the two
differences between the deep
access method for non-local
access in dynamic-scoped
languages and the static chain
method for static-scoped
languages?
The static chain method
requires more time to access
nonlocals
The deep access method is
directly related to the deep
binding method
The deep access method
requires that variable names
must be stored in the
activation records
With the static chain method,
the length of the chain to be
followed is statically known
For the deep access method,
which of the following are true?
Subprogram linkage is faster
than with the shallow access
method
Accesses to nonlocal
variables is faster than with
the shallow access method
Subprogram linkage is
slower than with the shallow
access method
Accesses to nonlocal
variables is slower than with
the shallow access method
8.
Which of the following
languages does not
support an
encapsulation
construct for a single
data type and its
operations?
C#
C++
Java
Ada 95
2.
The difference between an Ada
private type and a limited private
type is
Limited private types do not
allow access from static
parents
Limited private types do not
allow public access
Limited private types do not
allow access from clients
Limited private types do not
have any built-in operations
3.
Which of the following languages
do(es) not provide for destructors?
C++
Java
Ada 95
C#
4.
Which of the following is not a
reason why accessors for data
members are better than making
them public?
The implementation of the data
member can be changed
without affecting clients
Read-only access can be
specified
Accessors require less storage
Constraints can be included
with setters
5.
Which of the following languages
include parameterized abstract data
types?
Ada
Java
C#
C++
6.
Which of the following languages
support(s) nested subprograms?
Fortran 95
Ada
C++
C#
7.
Which of the following languages
support(s) packages as naming
encapsulations?
C++
Java
C#
Ada
8.
Which of the following are kinds of
Ada packages?
Private packages
Body packages
Procedure packages
Specification packages
9.
In which of the following languages
are all objects created on the heap?
C++
Java
Ada
C#
10 .
In which of the following languages
can a method be defined outside the
class in which its object is defined?
Java
Ada
C++
C#
11 .
Which of the following visibility
constraints cannot be specified,
either implicitly or explicitly, in Ada?
Internal
Public
Private
Protected
12 .
Which of the following languages
use header files for interfaces to
library files?
C++
C
Java
Ada
Which of the following
is not a design issue for
object-oriented
languages?
Are subclasses
subtypes?
Single versus
multiple
inheritance
The exclusivity of
objects
Are methods
required to return
only objects?
2.
Which of the following languages support
OOP and procedure-oriented
programming?
C++
Java
Smalltalk
Ada 95
3.
Which of the following set Smalltalk apart
from more conventional languages such
as Java and C++?
Variables are not typed
Messages can take parameters
Dynamic type checking
Subclasses can define their own
instance variables
4.
Which of the following languages
supports different kinds of inheritance, in
terms of access control?
C++
Smalltalk
Java
Ada 95
5.
Which of the following languages support
both static and dynamic binding of
method calls to methods?
Java
Smalltalk
C++
Ada 95
6.
A C++ abstract class is one that
Has no method definitions
Has no class variables
Has at least one pure virtual
function
Has no named constants
7.
In which of the following languages are
all bindings of method calls to methods
dynamic?
Ada 95
C++
Smalltalk
Java
8.
A Java interface is which of the
following?
The protocol of a method
The protocol to all of the exception
handlers in a class
A kind of abstract class
An alternative to multiple
inheritance
9.
In which of the following languages must
overriding methods be marked as such?
Smalltalk
Java
C++
C#
10 .
In which of the following language are all
subclasses subtypes?
Java
C++
Ada 95
C#
11 .
Which of the following distinguishes
JavaScript objects from those of Java?
All object members are either
primitives or references
Objects do not have types
The number of object members is
dynamic
Any object can include a method
member
12 .
The implementations of which of the
following languages may require multiple
vtables for its classes?
Smalltalk
C++
C#
Java
13 .
Which of the following languages have
two distinct uses of the reserved word,
private?
Java
C#
C++
Ada 95
14 .
In which of the following languages can
objects be stack allocated?
C#
Java
Ada 95
C++