250+ TOP MCQs on Runtime Storage Location and Answers

Compilers Multiple Choice Questions & Answers (MCQs) on “Runtime Storage Location”.

1. The instruction ‘ORG O’ is a ______
a) Machine Instruction
b) Pseudo instruction
c) High level instruction
d) Memory instruction

Answer: b
Clarification: It is a pseudo instruction.

2. ‘Aging registers’ are _______
a) Counters which indicate how long ago their associated pages have been Referenced
b) Registers which keep track of when the program was last accessed
c) Counters to keep track of last accessed instruction
d) Counters to keep track of the latest data structures referred

Answer: a
Clarification: This is known as aging.

3. Memory unit accessed by content is called ______
a) Read only memory
b) Programmable Memory
c) Virtual Memory
d) Associative Memory

Answer: d
Clarification: Associative Emory is accessed by content.

4. _________ register keeps tracks of the instructions stored in program stored in memory.
a) AR (Address Register)
b) XR (Index Register)
c) PC (Program Counter)
d) AC (Accumulator)

Answer: c
Clarification: Program counter keeps a track.

5. N bits in operation code imply that there are ___________ possible distinct Operators.
a) 2n
b) 2n
c) n/2
d) n2

Answer: b
Clarification: 2n possible combinations.

6. A three input NOR gate gives logic high output only when _____________
a) One input is high
b) One input is low
c) Two input are low
d) All input are high

Answer: d
Clarification: All inputs are high.

7. The circuit converting binary data in to decimal is_____
a) Encoder
b) Multiplexer
c) Decoder
d) Code converter

Answer: d
Clarification: It is the code converter.

8. The multiplicand register & multiplier register of a hardware circuit implementing booth’s algorithm have (11101) & (1100). The result shall be ______
a) (812)10
b) (-12)10
c) (12)10
d) (-812)10

Answer: a
Clarification: On multiplying we get 81210.

9. PSW is saved in stack when there is a ________
a) Interrupt recognized
b) Execution of RST instruction
c) Execution of CALL instruction
d) All of the mentioned

Answer: a
Clarification: It can be interrupted.

10. In computers, subtraction is carried out generally by __________
a) 1’s complement method
b) 2’s complement method
c) signed magnitude method
d) BCD subtraction method

Answer: b
Clarification: Subtraction done by 2’s complement.

250+ TOP MCQs on Finite Automata and Regular Expressions

Compilers Interview Questions and Answers on “Finite Automata and Regular Expressions”.

1. Which of the following strings is not generated by the following grammar?

            
 S → SaSbS|ε

a) aabb
b) abab
c) aababb
d) aaabbb

Answer: d
Clarification: Given S → SaSbS|ε
S->aSbS putting S-> € and then S->SaSbS
S->aSaSaSbSbSbS putting S->SaSbS
S->aaabbb putting S->€.

2. Regular expressions can be used only for values of type string and number.
a) True
b) False

Answer: b
Clarification: RE is used for all types of string and numbers.

3. What is the Regular Expression Matching Zero or More Specific Characters?
a) x
b) #
c) *
d) &

Answer: c
Clarification: Zero or Specific Expression matching can be done only by a single character that is*.

4. All __________ are automatically treated as regular expressions.
a) Programmatic description
b) Window
c) Win Object
d) Collection

Answer: a
Clarification: It is seen that programmatic description are treated as regular expression.

5. Regular Expressions can be used with XML checkpoints.
a) True
b) False

Answer: a
Clarification: XML checkpoints employ RE.

6. The production Grammar is {S->aSbb,S->abb} is __________ grammar.
a) Type-3
b) Type-2
c) Type-1
d) Type-0

Answer: b
Clarification: As per the definition of type-2 grammar.

7. Regular expression (x/y)(x/y) denotes which of the following set?
a) {xy,xy}
b) {xx,xy,yx,yy}
c) {x,y}
d) {x,y,xy}

Answer: b
Clarification: From first part if we take x then from the latter part x then it forms xx
From first part if we take x then from the latter part y then it forms xy
From first part if we take y then from the latter part x then it forms yx
From first part if we take y then from the latter part y then it forms yy.

8. Regular expression x/y denotes which of the following set?
a) {x,y}
b) {xy}
c) {x}
d) {y}

Answer: a
Clarification: Because either x or y can be selected.

9. The regular expressions denote zero or more instances of an x or y is?
a) (x+y)
b) (x+y)*
c) (x* + y)
d) (xy)*

Answer: b
Clarification: For instances of x or y the exp is x+y and both can zero or more times than (x+y)*.

250+ TOP MCQs on The NFA with epsilon – Moves and Answers

Compilers Questions and Answers for Experienced people on “The NFA with Epsilon – Moves”.

1. NFA-εs are defined because certain properties can be more easily proved on them as compared to NFA.
a) True
b) False

Answer: a
Clarification: NFA-ε can be transformed into a NFA always, the properties are also true for NFAs.

2. E(q) is known ε-closure of q.
a) True
b) False

Answer: a
Clarification: The ε-closure of a set of states Z of an NFA is defined as the set of states reachable from any state in Z following ε-transitions.

3. ε-transitions does not add any extra capacity of recognizing formal.
a) True
b) False

Answer: a
Clarification: ε-transitions provides a convenient transition in the systems whose current states are not precisely known.

4. Which of the following CFG’s can’t be simulated by an FSM?
a) S->Sa/b
b) S->aSb/ab
c) S->abX, X->cY, Y->d/aX
d) None of the mentioned

Answer: b
Clarification: generates the set {an bn, n=1,2,3 ….}which is not regular.

5. The transitions which does not take an input symbol are called ___________
a) ε-transitions
b) λ-transitions
c) ε-transitions & λ-transitions
d) none of the mentioned

Answer: c
Clarification: The transitions taking an input symbol are called ε-transitions or λ-transitions.

6. A nondeterministic finite automation with ε-moves is an extension of nondeterministic finite automation.
a) True
b) False

Answer: a
Clarification: Both are equivalent.

7. Is an ordinary NFA and a NFA-ε are equivalent.
a) True
b) False

Answer: a
Clarification: Yes ordinary NFA and NFA-ε are the same, in that, given either one, one can construct the other, which recognizes the same language.

8. Which of the following is a correct statement?
a) { If an bn | n = 0,1, 2, 3 ..} is regular language
b) Strings with equal number of a’s and b’s denies a regular language
c) L (A* B*)∩ B gives the set A
d) None of the mentioned

Answer: c
Clarification: If we include A and B in a set and if we write A* it means except then A i.e. B same as B* means except then B i.e. so if we intersect (A*B*) and B then get A because in any regular language. If we write A-B then A-B=A intersection B’ so if we intersect A and B means A-B So the intersection of (A*B*) and B = (BA). intersection B means (BA)-B’ and B’=A so (BA) intersection(A)=A.

250+ TOP MCQs on Right Left Linear Grammar and Answers

Compilers Mcqs on “Right Left Linear Grammar”.

1. Left Linear grammar can be converted to Right Linear grammar.
a) Yes
b) No

Answer: a
Clarification: Since right-linear grammars are regular, it follows that left-linear grammars are also regular.

2. What is CFG?
a) Compiler
b) A language expression
c) Regular Expression
d) None of the mentioned

Answer: b
Clarification: They are defined by rule A->b where A is non terminal and b is terminal.

3. What is the idea of automation with a stack as auxiliary storage?
a) Finite automata
b) Push Down Automata
c) Deterministic Automata
d) None of the mentioned

Answer: b
Clarification: Push Down Automata manipulate the Stack as a part of performing a transition.

4. Transition of finite automata is ___________
a) Finite Diagram
b) State Diagram
c) Node Diagram
d) E-R Diagram

Answer: b
Clarification: Transition of finite automata is Finite Diagram.

5. A context free language is called ambiguous if?
a) It has 2 or more than 2 left derivations for some terminal string ѡ є L (G)
b) It has 2 or more than 2 right derivations for some terminal string ѡ є L (G)
c) It has 2 or more than 2 left and right derivations for some terminal string ѡ є L (G)
d) None of the mentioned

Answer: c
Clarification: When two or more Left and right most derivative occur the grammar turn ambiguous .

6. Which of the following statement is true?
a) Every language that is defined by regular expression can also be defined by finite automata
b) Every language defined by finite automata can also be defined by regular expression
c) We can convert regular expressions into finite automata
d) All of the mentioned

Answer: d
Clarification: All these statements are true w.r.t regular expression.

7. Which of the following identity is wrong?
a) R + R = R
b) (R*)* = R*
c) ƐR = Rɛ = R
d) ØR = RØ = RR*

Answer: d
Clarification: Regular grammar combined with empty does not give R* instead gives empty.

8. Grammars that can be translated to DFAs is __________
a) Left linear grammar
b) Right linear grammar
c) Generic grammar
d) All of the mentioned

Answer: b
Clarification: Right Linear grammar can be translate to DFA.

9. A language is regular if and only if it is accepted by finite automata.
a) The given statement statement is true
b) Given statement is false
c) Statement is partially true
d) None of the mentioned

Answer: a
Clarification: Regular Language is accepted by Finite Automata. Every regular language is Context free.

10. A Push Down Automata is if there is at most one transition applicable to each configuration?
a) Deterministic
b) Non deterministic
c) Finite
d) Non finite

Answer: a
Clarification: In every situation, only one transition is available as continuation then the result is deterministic push down automata.

250+ TOP MCQs on L-Attributed Definition and Answers

Compilers Multiple Choice Questions & Answers (MCQs) on “L-Attributed Definition”.

1. Dynamic linking can cause security concerns because ______________
a) Security is dynamic
b) None of the mentioned
c) Security is dynamic & Cryptographic procedures are not available for dynamic linking
d) Cryptographic procedures are not available for dynamic linking

Answer: d
Clarification: Required by the program are linked during run time.

2. Which of the following statements is FALSE?
a) In up-typed languages, values do not have any types & Dynamic languages have no variables types
b) In up-typed languages, values do not have any types
c) Dynamic languages have no variables types
d) None of the mentioned

Answer: c
Clarification: They have dynamically changing types.

3. What is grammar?

S -> C C 
C -> eC | d 

a) LL (1)
b) SLR (1) but not LL (1)
c) LALR (1) but not SLR (1)
d) LR (1) but not LALR (1)

Answer: c
Clarification: The grammar is CLR and can be reduced to LALR.

4. The 3-address code sequence generated by which definition?

S -> id: = E " 
newtemp ();
 gen(t . place . place;); .place t} " 
.place .place;}
For the statement ‘X: = Y + Z ’,

a) X = Y + Z
b) t1 = Y + Z; X t1
c) t1 = Y; t2 = t1 + Z; X = t2
d) t1 = Y; t2 = Z; t3 + t2; X = t3

Answer: d
Clarification: In 3-address code we use temporary variables.

5. If the programming language uses static scoping and call by need parameter passing mechanism, the values printed will be?
a) 115, 220
b) 25, 220
c) 25, 15
d) 115, 105

Answer: d
Clarification: So i = 100 & j = 5 P (i + j) = P (100 + 5) = P(105) So x = 105 x + 10 = 105 + 10 = 115 So 115 & 105 will be printed.

6. If dynamic scoping is used and call by name mechanism is used, the values printed will be?
a) 115, 220
b) 25, 220
c) 25, 15
d) 115, 105

Answer: b
Clarification: Since x = i + j & in P (x) i = 200 & j = 20 x = 200 + 20 = 220 & printing (x + 10) 9. = i + j + 10 = 10 + 5 + 10 = 25.

7. What will be the output of the following code?

P x =new Q();
Q y =new Q();
P z =new Q(); 
x. f (1);
((P) y). f (1);
z.f(1);

a) 1 2 1
b) 2 1 1
c) 2 1 2
d) 2 2 2

Answer:d
Clarification: Here,

1. Px = newQ();
2. Qy = newQ();
3. Pz = newQ(); 
4. x : f(1); 
print 2 # i = 2
5. ((P) y) :f(1); 
6. z : f(1) print 2 # i = 2 

but line 6. will print 2 because typecast to parent class can’t prevent over ridding.

8. Which of the following is NOT an advantage of using shared, dynamically linked libraries as compared to statically linked libraries?
a) Smaller sizes of executable
b) Lesser overall page fault rate in the system
c) Faster program start-up
d) Existing programs need not be re-linked to take advantage of newer versions of libraries

Answer: c
Clarification: No need for re-linking if newer versions of libraries are there.

9. Which grammar violate rules of an operator grammar?

(i)	P-> QR 
(ii)	P -> Q s R 
(iii)	P -> ε 
(iv)	P ->Q t

a) (i) only
b) (i) and (iii) only
c) (ii) and (iii) only
d) (iii) and (iv) only

Answer: b
Clarification: (I) P ” QR is not possible since two NT should include one operator as Terminal.

10. Consider the grammar rule. E -> E1 − E2 for arithmetic expressions. If E1 and E2 do not have any common sub expression, in order to get the shortest possible code.
a) E1 should be evaluated first
b) E2 should be evaluated first
c) Evaluation of E1 and E2 should necessarily be interleaved
d) Order of evaluation of E1 and E2 is of no consequence

Answer: b
Clarification: E1 is to be kept in accumulator & accumulator is required for operations to evaluate E2.

250+ TOP MCQs on Symbol Table Organization and Answers

Compilers Multiple Choice Questions & Answers (MCQs) on ” Symbol Table Organization″.

1. The main memory in a Personal Computer (PC) is made of __________
a) Cache memory
b) Static RAM
c) Dynamic Ram
d) Cache memory & RAM

Answer: d
Clarification: It is made up of cache memory and RAM.

2. Cache memory works on the principle of _________
a) Locality of data .
b) Locality of memory
c) Locality of reference
d) Locality of reference & memory

Answer: c
Clarification: Cache works on Locality of reference.

3. An n-bit microprocessor has __________
a) n-bit program counter
b) n-bit address register
c) n-bit ALU
d) n-bit instruction register

Answer: d
Clarification: N bit microprocessor has bit instruction register.

4. When CPU is executing a Program that is part of the Operating System, it is said to be in __________
a) Interrupt mode
b) System mode
c) Half mode
d) Simplex mode

Answer: b
Clarification: It is in System Mode.

5. Logic X-OR operation of (4ACO) H & (B53F) H results __________
a) AACB
b) 0000
c) FFFF
d) ABCD

Answer: c
Clarification: Xoring the two operands we get FFFF.

6. If the main memory is of 8K bytes and the cache memory is of 2K words. It uses associative mapping. Then each word of cache memory shall be __________
a) 11 bits
b) 21 bits
c) 16 bits
d) 20 bits

Answer: c
Clarification: Each should be 8*2=16 bits.

7. A Stack-organised Computer uses instruction of __________
a) Indirect addressing
b) Two-addressing
c) Zero addressing
d) Index addressing

Answer: c
Clarification: Zero addressing modes are used in stack organised computer.

8. In a program using subroutine call instruction, it is necessary ___________
a) Initialize program counter
b) Clear the accumulator
c) Reset the microprocessor
d) Clear the instruction register

Answer: d
Clarification: It is mandatory to clear the instruction register.

9. Virtual memory consists of _________
a) Static RAM
b) Dynamic RAM
c) Magnetic memory
d) None of the mentioned

Answer: a
Clarification: It does consist of static RAM.

10. In signed-magnitude binary division, if the dividend is (11100)2 and divisor is (10011)2 then the result is _________
a) (00100)2
b) (10100)2
c) (11001)2
d) (01100)2

Answer: b
Clarification: After division we get 20 which is 10100.