A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

1. The number of tokens in the following C statement is

printf("i = %d, &i = %x", i, &i);
a. 3
b. 26
c. 10
d. 21
View Answer Report Discuss Too Difficult! Search Google
Answer: (c).10

2. In a compiler, keywords of a language are recognized during
a. parsing of the program
b. the code generation
c. the lexical analysis of the program
d. dataflow analysis
View Answer Report Discuss Too Difficult! Search Google
Answer: (c).the lexical analysis of the program

3. The lexical analysis for a modern computer language such as Java needs the power of which one of the following machine models in a necessary and sufficient sense?
a. Finite state automata
b. Deterministic pushdown automata
c. Non-Deterministic pushdown automata
d. Turing Machine
View Answer Report Discuss Too Difficult! Search Google
Answer: (a).Finite state automata

4. What is the maximum number of reduce moves that can be taken by a bottom-up parser for a grammar with no epsilon- and unit-production (i.e., of type A -> є and A -> a) to parse a string with n tokens?
a. n/2
b. n-1
c. 2n-1
d. 2^n
View Answer Report Discuss Too Difficult! Search Google
Answer: (b).n-1

5. Consider the following two sets of LR(1) items of an LR(1) grammar.

X -> c.X, c/d
X -> .cX, c/d
X -> .d, c/d
X -> c.X, $
X -> .cX, $
X -> .d, $

Which of the following statements related to merging of the two sets in the corresponding LALR parser is/are FALSE?

1. Cannot be merged since look aheads are different.
2. Can be merged but will result in S-R conflict.
3. Can be merged but will result in R-R conflict.
4. Cannot be merged since goto on c will lead to two different sets.
a. 1 only
b. 2 only
c. 1 and 4 only
d. 1, 2, 3, and 4
View Answer Report Discuss Too Difficult! Search Google
Answer: (d).1, 2, 3, and 4

6. The grammar S → aSa | bS | c is
a. LL(1) but not LR(1)
b. LR(1)but not LR(1)
c. Both LL(1)and LR(1)
d. Neither LL(1)nor LR(1)
View Answer Report Discuss Too Difficult! Search Google
Answer: (c).Both LL(1)and LR(1)

7. Match all items in Group 1 with correct options from those given in Group 2.

Group 1 Group 2

P. Regular expression 1. Syntax analysis
Q. Pushdown automata 2. Code generation
R. Dataflow analysis 3. Lexical analysis
S. Register allocation 4. Code optimization
a. P-4. Q-1, R-2, S-3
b. P-3, Q-1, R-4, S-2
c. P-3, Q-4, R-1, S-2
d. P-2, Q-1, R-4, S-3
View Answer Report Discuss Too Difficult! Search Google
Answer: (b).P-3, Q-1, R-4, S-2

8. Which of the following statements are TRUE?

I. There exist parsing algorithms for some programming languages
whose complexities are less than O(n^3).
II. A programming language which allows recursion can be implemented
with static storage allocation.
III. No L-attributed definition can be evaluated in The framework
of bottom-up parsing.
IV. Code improving transformations can be performed at both source
language and intermediate code level.
a. I and II
b. I and IV
c. III and IV
d. I, III and IV
View Answer Report Discuss Too Difficult! Search Google
Answer: (b).I and IV

9. Which of the following describes a handle (as applicable to LR-parsing) appropriately?
a. It is the position in a sentential form where the next shift or reduce operation will occur
b. It is non-terminal whose production will be used for reduction in the next step
c. It is a production that may be used for reduction in a future step along with a position in the sentential form where the next shift or reduce operation will occur
d. It is the production p that will be used for reduction in the next step along with a position in the sentential form where the right hand side of the production may be found
View Answer Report Discuss Too Difficult! Search Google
Answer: (d).It is the production p that will be used for reduction in the next step along with a position in the sentential form where the right hand side of the production may be found

10. An LALR(1) parser for a grammar G can have shift-reduce (S-R) conflicts if and only if
a. the SLR(1) parser for G has S-R conflicts
b. the LR(1) parser for G has S-R conflicts
c. the LR(0) parser for G has S-R conflicts
d. the LALR(1) parser for G has reduce-reduce conflicts
View Answer Report Discuss Too Difficult! Search Google
Answer: (b).the LR(1) parser for G has S-R conflicts

Page 1 of 5