Question 1 (0.5 points) Question 1 Unsaved Which of the following statements are
ID: 3692834 • Letter: Q
Question
Question 1 (0.5 points) Question 1 Unsaved
Which of the following statements are true?
I) Pattern matching and string/text algorithms (e.g., substring matching, regular expression matching, longest common subsequence algorithms) are commonly used within the scanner portion of a language compiler or interpreter.
II) Parsers convert program text into tokens for use by a scanner.
III) Regular expressions describe context free grammars.
IV) LALR(1) parsers use "look-ahead" to simplify parser implementation while improving memory usage and performance. However, there exist LR(1) languages/grammars that are not parseable with LALR parsers.
V) An LR(1) parser is an LR(k) parser for k=1, i.e. with a single lookahead terminal.
Question 1 options:
I, IV, and V
I and III
I and V
IV and V
II and III
Save
Question 2 (1 point) Question 2 Unsaved
Which of the following statements are true?
I) An LR parser (Left to right, Rightmost derivation parser) is a type of shift-reduce parser. This parser has the potential of recognizing all deterministic context-free languages and can produce both left and right derivations of statements encountered in the input file.
II) LR parsers have historically required more memory to implement compared to LL parsers for the same language.
III) Lookahead establishes the maximum number of incoming tokens that a parser can use to decide which rule to apply. Lookahead for LL and LR parsers is often explicitly indicated by affixing the lookahead to the algorithm name in parentheses, such as LALR(1) meaning exactly one lookahead token is used.
IV) Backtracking is a general algorithm for finding all (or some) solutions to constraint satisfaction problems. Such algorithms incrementally build candidates to the solutions, and abandon each partial candidate as soon as it determines the candidate cannot possibly be completed to a valid solution.
V) Not every language recognizable by an LL(1) parser is recognizable by an LR(1) parser.
Question 2 options:
II and III
I, III, and IV
only II
I, II, III, IV, and V
I, II, III, and IV
Save
Question 3 (0.5 points) Question 3 Unsaved
Which of the following statements are true?
I) Dynamic dispatch is the process of selecting which implementation of a polymorphic operation (method or function) to call at run time. Dynamic dispatch contrasts with static dispatch in which the implementation of a polymorphic operation is selected at compile-time.
II) Dynamic dispatch is often used in object-oriented languages when different classes contain different implementations of the same method due to common inheritance. C++ virtual member functions are an example of dynamic dispatch.
III) Dynamic dispatch is a technique for avoiding the fragile base class problem.
IV) C++ compilers typically implement dynamic dispatch with a data structure called a vtable that defines the member function invocation to member function implementation mapping for a given class. Instances of C++ classes that define or inherit one or more virtual member functions store a pointer to a vtable as part of their instance data.
Question 3 options:
I, II, III, and IV
II, III, and IV
I, II, and III
I, II, and IV
only II
Save
Question 4 (0.5 points) Question 4 Unsaved
Which of the following statements are true?
I) A function or expression is said to have a side effect if, in addition to returning a value, it also modifies some state or has an observable interaction with calling functions or the outside world. For example, a function might modify a global variable, raise an exception, or write data to a file. Understanding and debugging a function with side effects requires knowledge about the context and order of evaluation.
II) In functional programming, side effects are typically avoided. For example, functional languages such as Standard ML, Scheme, and Scala do not restrict side effects, but it is customary for programmers to avoid them.
III) The use of side effects simplifies concurrent/parallel programming and code execution.
IV) Assembly language programmers must be aware of hidden side effects — instructions that modify parts of the processor state which are not mentioned in the instruction's mnemonic. A classic example of a hidden side effect is an arithmetic instruction that implicitly modifies condition codes (a hidden side effect) while it explicitly modifies a register (the overt effect).
Question 4 options:
I, II, III, and IV
I and II
I, II, and IV
I, II, and III
Save
Question 5 (0.5 points) Question 5 Unsaved
Which of the following statements are true?
I) In object-oriented programming, an iterator is used to traverse a container/collection and access the container's elements. The iterator pattern decouples algorithms from containers.
II) Use of immutable variables prevents side-effects and enables safe aliasing of references.
III) First-class functions may be passed as arguments to other functions, returned as the values from other functions, and may be assigned to variables or stored in data structures.
IV) First-class functions are a necessity for the functional programming style. A simple usage example is the map function, which takes, as its arguments, a function and a list, and returns the list formed by applying the function to each member of the list. To implement map, it must be possible to pass a function (or at least a pointer to a function) as an argument.
V) The C standard library function, qsort(), is an example of using a first class function in a language that is not generally considered to be a "functional" programming language.
Question 5 options:
I, II, III, IV, and V
I, II, and III
I, II, III, and IV
II, III, and IV
I and II
Save
Question 6 (1 point) Question 6 Unsaved
Which of the following statements are true?
I) An anonymous function (a.k.a lambda function) is a function definition that is not bound to an identifier.
II) A closure (a.k.a. function closure) is a function or reference to a function together with a referencing environment—a table storing a reference to each of the non-local variables of that function. A closure—unlike a plain function pointer—enables a function to access those non-local variables even when invoked outside its immediate lexical scope.
III) Closures capture the run-time environment at the time/point the function is declared as opposed to the run-time environment at the time the function is executed.
IV) One difference between Common LISP and Scheme is that Scheme implements closures but Common LISP does not.
Question 6 options:
II, III, and IV
I, II, III, and IV
I and II
I, II, and III
Save
Question 7 (0.5 points) Question 7 Unsaved
Which of the following statements are true?
I) A higher-order function is a function that takes one or more functions as an input.
II) Most functional programming languages are derived from the ideas of lambda calculus in mathematics.
III) The map and fold functions, found in many functional programming languages, are examples of higher-order functions.
IV) Neither C++ as of the C++11 standard nor Java 8 provide language level support for lambda functions or higher-order functions.
V) In the Church–Turing Thesis, the untyped lambda calculus is claimed to be capable of computing all effectively calculable functions and is therefore logically equivalent to a Universal Turing Machine.
Question 7 options:
II, III, and IV
I, II, III, and IV
I, II, III, V
I and II
I, II, and V
Save
Question 8 (0.5 points) Question 8 Unsaved
Which of the following statements are true?
I) Static type-checking is the process of verifying the type safety of a program based on analysis of a program's source code. If a program passes a static type-checker, then the program is guaranteed to satisfy some set of type-safety properties for all possible inputs. Because static type-checking operates on a program's text, it allows many bugs to be caught early in the development cycle.
II) Dynamic type-checking is the process of verifying the type safety of a program at run-time.
III) The presence of static type-checking in a programming language prevents use of dynamic type-checking.
IV) Static typing advocates believe programs are more reliable when they have been well type-checked early in the development cycle, while dynamic typing advocates point to a large and growing body of code that has proven reliable without static type checking. The opposing views reflect different emphasis on the trade-offs between more effort by programmers and compilers up-front to avoid potential errors vs. finding certain categories of errors only at run-time.
V) Some proponents of dynamic type checking observe that it is impossible for compilers to identify all program bugs at compile time. Therefore, extensive testing is always required if the goal is to eliminate bugs. If extensive tests are used, type errors that might have been detected by a static type checker at compile time will be detected when testing even when dynamic typing is used. Since type errors will be caught whether static type checking used or not, the decision to use static type checking or not should be based on wether one approach or the other promotes more programmer productivity. For example, if programmers save time by using dynamic typing, then the programmers will have more time to develop tests.
Question 8 options:
I, II, and IV
I, II, III
I, II, IV, V
I and II
I, II, III, and IV
Save
Question 9 (1 point) Question 9 Unsaved
Which of the following statements are true?
I) Interpreters, compilers, type-checkers, and documentation generators are examples of programs that take other programs as input.
II) An abstract syntax tree is a tree data structure representation of the abstract syntactic structure of source code written in a programming language. Each node of the tree denotes a construct occurring in the source code.
III) Abstract syntax tree data structures represent every detail appearing in the program syntax.
IV) Context free grammars prevent the possibility of ambiguity in programming languages.
Question 9 options:
I, II, III, and IV
II, III, IV
I, II
I, II, IV
Save
Question 10 (0.5 points) Question 10 Unsaved
Which of the following statements are true?
I) Interpreters may translate input programs into executable code.
II) Compilers may translate input programs into executable code.
III) Some compilers and interpreters translate input programs into portable intermediate code.
IV) Just-in-time compilers are a practical example of "Dynamic Machine Code Generation".
Question 10 options:
I and II
I, II, and IV
I, II, III, and IV
I, II, III
Save
Question 11 (0.5 points) Question 11 Unsaved
Which of the following statements are true?
I) Program run-time environments that provide automatic memory garbage collection eliminate the possibility of run-time errors.
II) Thanks to automatic garbage collection, there is no such thing as a Java NullPointerException.
III) Garbage collection is a form of automatic memory management that usually provides automatic management of non-memory resources such as file descriptors and semaphores as well.
IV) The moment when the garbage is actually collected can be unpredictable, resulting in stalls scattered throughout a session. Unpredictable stalls can be unacceptable in real-time environments, in transaction processing, or in interactive programs. Incremental, concurrent, and real-time garbage collectors address these problems, with varying trade-offs.
Question 11 options:
I, III, and IV
only IV
I and II
I, II, III, and IV
III, and IV
Save
Question 12 (0.5 points) Question 12 Unsaved
Which of the following statements are true?
I) Reference counting has been in use since the dawn of computer programming.
II) Reference counting is deterministic..
III) Reference counting may be used with non memory resources such as file descriptors and semaphores.
IV) Reference counting is used by Microsoft's COM, the Linux Kernel, C++11 std::shared_ptr, most implementations of Python, Objective-C, Swift, and other programming languages.
Question 12 options:
II, and IV
I, II, III, and IV
I, II, and III
II, and III
I and II
Save
First-Year Programming Concepts
Question 13 (0.25 points) Question 13 Unsaved
What purpose does the class construct serve?
Question 13 options:
A)
Promotes code reuse and data encapsulation
B)
Provides a convenient way of modeling real-world objects
C)
Forces programmer to make all the implementation details explicit.
D)
Promotes code optimization.
E)
Both (A) and (B) are true.
Save
Question 14 (0.25 points) Question 14 Unsaved
Inheritance makes it easier to:
Question 14 options:
A)
Reuse and modify existing modules of code.
B)
Write and read code by sharing method names.
C)
Hide and protect data from external code.
D)
Both A and B.
E)
All of the above.
Save
Question 15 (0.25 points) Question 15 Unsaved
Which statement is true? (members = fields and methods)
Question 15 options:
A)
A base class inherits some of the members of a derived class.
B)
A base class inherits all the members of a derived class.
C)
A derived class inherits some of the members of a base class.
D)
A derived class inherits all members of a base class.
E)
None of the above.
Save
Question 16 (0.25 points) Question 16 Unsaved
With inheritance, the derived class
Question 16 options:
1)
should be usable in any situation where an instance of the base class is usable (Liskov Substitution Principle)
2)
cannot use fields of the base class
3)
cannot have any fields.
4)
must have fields.
Save
Question 17 (0.25 points) Question 17 Unsaved
At least in Java and C++, if class A is derived from class B and class B is derived from class C, polymorphism allows
Question 17 options:
1)
references to objects of type A can be stored in variables that store references to type B
2)
references to objects of type A can be stored in variables that store references to type C
3)
objects of type C can be stored in variables if type B
4)
1 and 2
5)
all of the above
Save
Computer Organization
Question 18 (0.25 points) Question 18 Unsaved
_______ is when a computers system is in a near constant state of reading and writing to a pagefile/swapfile.
Question 18 options:
1)
caching
2)
thrashing
3)
addressing
4)
faulting
Save
Data Structures and Algorithms
Question 19 (0.25 points) Question 19 Unsaved
public static void main(String[] args)
{
A a = new B();
a.method();
}
public class A {
public void method(){
System.out.println("In Parent");
}
}
public class B extends A {
@Override
public void method(){
System.out.println("In child");
}
}
If the code above is run what will be printed?
Question 19 options:
1)
“In Parent”
2)
“In child”
3)
both a and b
4)
An error is produced
Save
Question 20 (0.25 points) Question 20 Unsaved
Array ary is shown below
‘h’
‘i’
‘j’
‘k’
If 2 is passed to the method printArray below, what will the output be?
public static void printArray(int index){
if (index == 0 ){
System.out.print(ary[index]);
}
else {
printArray(index -1);
System.out.print(ary[index]);
}
}
Question 20 options:
1)
“hijk”
2)
“kjih”
3)
“hij”
4)
“jih”
5)
"h"
Save
Question 21 (0.5 points) Question 21 Unsaved
Select all of the following statements that are true.
Question 21 options:
A)
High level programming languages were created to increase programmer productivity and thereby minimize the cost and schedule of software development.
B)
To quote Donald Knuth, "Beware of bugs in the above code; I have only proved it correct, not tried it." (http://www-cs-faculty.stanford.edu/~knuth/faq.html) Programming languages exist that can prove incontrovertibly that non-trivial programs are correct and therefore bug-free.
C)
Programming languages that maximize individual programmer productivity do not always maximize the aggregate productivity of a team of programmers.
D)
It is usually impractical or impossible to write "system software" for von Neumann architecture computers without the use of pointers to access memory.
Save
Question 22 (0.5 points) Question 22 Unsaved
Select all of the following statements that are true.
Question 22 options:
A)
Edsger Dijkstra's letter, "Go To Statement Considered Harmful," published in the March 1968 Communications of the ACM (CACM), criticized the excessive use of the GOTO statement in programming languages of the day and advocated structured programming instead.
B)
The following two C code blocks are logically equivalent:
{ // Code block 1
int incr = 1;
int sum = 0;
while(incr < 20) {
while(sum <= 100) {
sum += incr;
}
incr++;
}
printf("%d ", sum);
}
{ // Code block 2
int incr = 1;
int sum = 0;
loop1: if(incr >= 20) goto out;
loop2: if(sum > 100) goto next;
sum += incr;
goto loop2;
next: incr++;
goto loop1;
out:
printf("%d ", sum);
}
C)
Scheme was developed at MIT in the 1970s and is characterized by small size and its treatment of functions as "first-class entities". As first-class entities, functions can be values of expressions, elements of lists, assigned to variables, passed as parameters, and returned as values.
D)
The C programming language is effectively a portable "Systems Programming" language.
Save
Question 23 (0.5 points) Question 23 Unsaved
Select all of the following statements that are true.
Question 23 options:
A)
Some programming languages are not Turing Complete.
B)
Java compiles source code into Byte Code. Byte Code may be interpreted or translated on the fly (Just In Time Compiled) into machine code.
C)
Some programming languages expose pointers as if they were numeric values and allow users to perform arithmetic on them. These languages are sometimes referred to as "weakly typed", since pointer arithmetic can be used to bypass the language's type system.
D)
Some programming languages can be interpreted or compiled on a case by case basis.
Save
Question 24 (0.5 points) Question 24 Unsaved
Select all of the following statements that are true.
Question 24 options:
A)
Type checking determines whether and when types are verified. Static checking means that type errors are reported based on a program's text (source code). Dynamic checking means that type errors are reported based on a program's dynamic (run-time) behavior.
B)
A "strong type system" is described as one in which there is no possibility of an unchecked run-time type error. In other words, the absence of unchecked run-time errors is referred to as safety or type safety
C)
Some programming languages do not have static type-checking. In many such languages, it is easy to write programs which would be rejected by most static type-checkers. For example, a variable might store either a number or the Boolean value "false". Some programmers refer to these languages as "weakly typed", since they do not seem to enforce the "strong" type discipline found in a language with a static type-checker.
D)
If simple operations do not behave in a way that one would expect, a programming language can be said to be "weakly typed". For example, consider the following program:
x = "5" + 6
Different languages will assign a different value to x:
One language might convert 6 to a string, and concatenate the two arguments to produce the string "56" (e.g. JavaScript)
Another language might convert "5" to a number, and add the two arguments to produce the number 11 (e.g. Perl, PHP)
Yet another language might represent the string "5" as a pointer to the first character of the string within memory, and add 6 to that pointer to produce another address (e.g. C)
And yet another language might simply fail to compile this program or report run-time errors saying that the two operands have incompatible type (e.g. Ruby, Python, BASIC)
Save
Question 25 (0.5 points) Question 25 Unsaved
Select all of the following statements that are true.
Question 25 options:
A)
Multiple consecutive whitespace characters (such as spaces, tabs, and new lines) outside literal quotations have meaning in Scheme programs.
B)
Every algorithm or problem solution we could describe using Python can also be described in Scheme.
C)
The Python statement x = 1 will act like Scheme's (define x 1) if there is no storage location already named x.
D)
Scheme is designed primarily for a functional programming style. This means most of a Scheme program is applying and defining functions. Python is designed primarily for an imperative programming style.
Save
Question 26 (0.5 points) Question 26 Unsaved
Select all of the following statements that are true.
Question 26 options:
A)
The Scheme statement,
(lambda (a b) (+ a b))
is equivalent to the Python statement,
lambda a, b: a + b
B)
The Scheme statements,
(define lst (list 10 20 30))
(car (cdr (cdr lst)))
are equivalent to the Python statements,
lst = [10, 20, 30]
print lst[2]
C)
The Scheme statement,
(define square (lambda (x) (* x x)))
is equivalent to the Python statement,
def square (x):
return x * x
D)
Like Scheme, Python has latent (invisible) types that are checked dynamically.
Save
Question 27 (0.5 points) Question 27 Unsaved
Select all of the following statements that are true.
Question 27 options:
A)
The following Racket function, func, is functionally identical to the Scheme standard map function. The type of the parameter f can be any valid Scheme type.
(define (func f lst)
(cond
[(empty? lst) empty]
[else (cons (f (first lst)) (func f (rest lst)))]
)
)
B)
In Python, a dictionary is a list of (key, value) pairs. The key can be any "immutable" object (tuples, strings, numbers), and the value can be any Python object.
C)
The Scheme statement,
(map (lambda (x)(* x x)) '(9 8 7 6))
evaluates to the list,
'(81 64 49 36)
D)
The Scheme constructor, cons, is used when you already have a list and you want to add one new element. Cons takes two arguments, an element and a list (in that order), and returns a new list whose car is the first argument and whose cdr is the second.
Save
Question 28 (0.5 points) Question 28 Unsaved
Select all of the following statements that are true.
Question 28 options:
A)
Because of the run time typing, Python's run-time must work harder than Java's. For example, when evaluating the expression a+b, the python run-time must first inspect the objects a and b to find out their type, which is not known at compile time. It then invokes the appropriate addition operation, which may be an overloaded user-defined method. Java, on the other hand, can perform an efficient integer or floating point addition but requires variable declarations for a and b, and Java does not allow overloading of the + operator for instances of user-defined classes.
B)
Python has dynamic typing and binding, and everything in Python is an object. As in Smalltalk, Python classes themselves are objects. In Python 3.5, built-in types can be used as base classes for extension by the user.
C)
The Python statement,
map(lambda x: x * x, [9, 8, 7, 6])
evaluates to the list,
[81, 64, 49, 36]
D)
A program written in Python will always take more time to execute that a logically equivalent program written in Java or C++.
Save
Question 29 (0.5 points) Question 29 Unsaved
Select all of the following statements that are true.
Question 29 options:
In computer science, an abstract syntax tree (AST) is a tree data structure representation of the abstract syntactic structure of source code written in a programming language. Each node of the tree denotes a construct occurring in the source code. The syntax is "abstract" in not representing every detail appearing in the real syntax. For instance, grouping parentheses are implicit in the tree structure, and a syntactic construct like an if-condition-then expression may be denoted by means of a single node with three branches.
Abstract syntax trees (ASTs) are used in program analysis and program transformation systems. For example, an interpreter may be created by visiting each node in an AST and executing operations appropriate for the node. A compiler may be created by visiting each node in an AST and generating machine code corresponding to operations appropriate for the node.
A context-free grammar (CFG) is a formal grammar in which every production rule is of the form
A ::- B
where A is a single nonterminal symbol, and B is a string of terminals and/or nonterminals (B can be empty). A grammar is considered "context free" when its production rules can be applied regardless of the context of a nonterminal. No matter which symbols surround it, the single nonterminal on the left hand side can always be replaced by the right hand side. This is what distinguishes it from a context-sensitive grammar.
A context-sensitive grammar (CSG) is a formal grammar in which the left-hand sides and right-hand sides of any production rules may be surrounded by a context of terminal and nonterminal symbols. Context-sensitive grammars are more general than context-free grammars, in the sense that there are some languages that cannot be described by context-free grammars, but can be described by CSG. A formal language that can be described by a context-sensitive grammar using a linear bounded automaton is called a context-sensitive language.
Save
Question 30 (0.5 points) Question 30 Unsaved
The ANSI/ISO C Grammar has a famous Shift/Reduce conflict. (Note: the ANSI/ISO C Grammar is available from multiple sources and is also in Pilot) Which of the following statements are true?
A) The conflict is also known as "the dangling else".
B) The YACC syntax BNF like rule/production that exhibits the Shift/Reduce conflict is contained in the following:
selection_statement
: IF '(' expression ')' statement ELSE statement
| IF '(' expression ')' statement
| SWITCH '(' expression ')' statement
;
C) The YACC syntax BNF like rule/production that exhibits the Shift/Reduce conflict is contained in the following:
compound_statement
: '{' '}'
| '{' block_item_list '}'
;
block_item_list
: block_item
| block_item_list block_item
;
D) When Shift/Reduce conflicts occur, YACC, BISON, and PLY parser generators resolve the conflict by Shifting as opposed to Reducing.
E) The ANSI/ISO C Grammar Shift/Reduce conflict will still exist if the selection_statement rule/production is changed to the following:
selection_statement
: IF '(' expression ')' compound_statement ELSE statement
| IF '(' expression ')' statement
| SWITCH '(' expression ')' statement
;
Question 30 options:
A, B, and D
Only C
A, B, C, D, and E
A nd E
B and E
A, B, D, and E
Save
Question 31 (0.5 points) Question 31 Unsaved
Which of the following statements is true:
A) The following regular expression matches real/floating point numbers with exponents:
[-+]?[0-9]*.?[0-9]+([eE][-+]?[0-9]+)?
B) The following regular expression matches valid ANSI/ISO C identifiers:
[A-Za-z_][A-Za-z_0-9]*
C) Regular expressions in general and Lex regular expressions in particular are context free and implementable using finite automata.
D) Natural languages are often context dependent. e.g. "Hit grandma with a club." vs. "Bugs Bunny hit grandma with a club." Supporting this form of context dependence has proven ideal in the specification of programming languages.
E) Scanners are typically implemented using regular expressions and a shift-reduce algorithm to identify tokens.
Question 31 options:
B and D
A, B, and C
Only C
A, B, C, D, and E
A and B
A, B, and E
Save
Question 32 (0.5 points) Question 32 Unsaved
Which of the following statements is true:
A) Scheme is a functional programming language and one of the two main dialects of the programming language Lisp.
B) In Scheme, the behavior of (car (car (car '((a b) (c d))))) is undefined or produces and error because (car '((a b) (c d))) is (a b), (car '(a b)) is a, and (car 'a) is undefined.
C) (car (car '((a b) (c d)))) yields 'a and (car (car (cdr '((a b) (c d))))) yields 'b.
D) All of the following are valid ways to write an abs(x) function that returns the absolute value of x:
(define abs
(lambda (n)
(if (< n 0) (- 0 n) n)
)
)
(define abs
(lambda (n)
((if (>= n 0) + -) 0 n)
)
)
(define abs
(lambda (n)
(if (>= n 0) n (- 0 n))
)
)
Question 32 options:
A, B, and D
A, B, and C
B and D
C and D
B and C
Save
Question 33 (0.5 points) Question 33 Unsaved
Which of the following statements is true:
A) Python is a multi-paradigm programming language that supports functional programming.
B) In Python, the behavior of [['a', 'b'],['c', 'd']][:-1][0][1] is undefined or an error.
C) In Python, [['a', 'b'],['c', 'd']][1][:-1] yields ['c'].
D) In Python, [x[:-1] for x in [['a', 'b'],['c', 'd']]] yields ['a', 'c']
E) All of the following are valid ways to write an Python abs(x) function that returns the absolute value of x:
abs = lambda x: -x if x < 0 else x
abs = lambda x: [-x, x][0 if x < 0 else 1]
def abs(x): return [lambda y: 0 - y, lambda y: y - 0][0 if x < 0 else 1](x)
F) Extended BNF notation is used to describe the syntax of Python expressions at https://docs.python.org/2/reference/expressions.html
Question 33 options:
B and D
A, C, E, and F
C and D
A and F
A, B, C, D, E, and F
B, D, and F
Explanation / Answer
Question 1:
I)True.
Pattern matching and string/text algorithms are done by the lexical analyzer (also called as scanner) of the compiler. Scanner converts the input into the tokens using predefined patterns.
Parsers are also called as Syntax analyzer. Tokens are produced by Lexical analyzer and then passed to parsers. Parsers takes the tokens and converts them into parse tree.
Regular language is generated by Regular Language and Context free grammars generate Context free grammar.
LALR Parsers are look ahead LR parsers. They use look ahead to simplify the parser implementation. LALR are less powerful than LR parsers but more powerful than SLR parsers. Therefore, there exists some LR(1) grammars that are not parseable with LALR parsers.
LR(k) parser has ‘k’ look ahead symbols. So, LR(1) has one look ahead symbol.
Thus, the Correct option is I, IV, and V.
Question 2:
LR parses guarantees to handle CFG in linear time.
LR parsers can handle huge range of languages and grammars in comparison to LL parsers. LL parser takes less memory than LR parsers.
Look ahead means the future symbols that the parser can handle. Generally, look ahead is explicitly provided with the parser name, such as LL(k) means k look ahead symbol.
Backtracking follows all possible path to find the solution. It rejects the path that will not lead to valid solution.
LL(1) languages are proper subset of LR(1) languages.
Thus, the correct option is I, II, III, IV, and V.
Question 3:
Dynamic dispatch is the process of selecting which polymorphic operation to call at run time.
Dynamic dispatch is mostly used in OOPS, wherein the polymorphism is used. Polymorphism is the phenomenon where methods have same name but different behavior.
Dynamic dispatch is used to avoid fragile base class problem by distinguishing the methods of the same name at the run time.
C++ implements dynamic dispatch by vtable.
Thus, the correct option is I, II, III, and IV
Question 4:
Functions have a side effect if it has any interaction outside its scope like modifying global variables.
In functional programming, side effects are generally avoided. The lack of the side effects makes it easier to do formal verification of a program.
Use of the side effects do not simplifies parallel programming and code execution. It simplifies imperative programming.
Assembly language programmers must be aware of hidden side effects.
Thus, the correct option is I, II, and IV
Question 5:
Iterator pattern is used to traverse the container elements. For example, in C# foreach is the iterator that traverses the collection.
Immutable variables are variables whose values cannot be changed example, constants. So they prevent side effects.
First class functions in programming are those which gives their functionality to others. They are passed as an argument to the other functions.
First class functions are used in OOPS and functional programing. Example of an first class function is map function which is passed as an argument to the other function.
The C standard function qsort is also a first-class function. std::sort is the other example.
Thus, the correct option is I, II, III, IV, and V.
Question 6:
Anonymous functions are the arguments passed to the higher order functions. They are not bound to an identifier.
Closure is a record storing a function together with the environment. It maps free variable with the function.
At run time the closure is formed when the outer function executes.
Both common lisp and Scheme implements Closure.
Thus, the correct option is I and II.
Question 7:
Higher order function is a function that takes one or more functions as argument.
Most of the functional programming is derived from the lambda calculus.
Higher order functions are those which takes other functions as argument. Map function is also used as argument.
C++ provides support for the higher order functions and Java provides partial support for the same.
In the Church–Turing Thesis, the untyped lambda calculus is claimed to be capable of computing all effectively calculable functions and is therefore logically equivalent to a Universal Turing Machine.
Thus, the correct option is I, II, III, and V.
Question 8:
It is the definition of the static type checking.
It is the definition of the dynamic type checking. Dynamic checking is used at run time.
Some languages like Java supports both the type of type casting.
Static typing advocates believe programs are more reliable when they have been well type-checked early in the development cycle, while dynamic typing advocates point to a large and growing body of code that has proven reliable without static type checking. Due to this the value of static typing has increased.
Sometimes it’s hard to find bugs at compile time. So dynamic typing is required.
Thus, the correct option is I, II, IV, and V.
Question 9:
Interpreter and compiler are the programs that takes other programs as input and give the desired output. Similarly type checkers and documentation generator does.
Abstract syntax tree is a tree data structure that is generated by syntax analyzer to show the syntactic structure of the source code.
Abstract syntax trees show every syntax of the program.
CFG prevent the possibility of ambiguity, by left factoring and left recursion.
Thus, the correct option is I, II, III, and IV
Question 10:
I)True.
Interpreters takes the program as input and compile it line by line. It converts the program into object code that is executable code.
Compiler takes the program as input and compile it completely. It converts the program into object code that is executable code.
Some compilers and interpreters translate input programs into portable intermediate code, for example, JIT compiles the code into intermediate code bytecode.
Just in time compilers convert the code into intermediate code with .exe extension. That code can be executed on any machine.
Thus, the correct option is I, II, III, and IV