You are on page 1of 8

R10

Code No: R22056

SET - 1

II B.Tech II Semester, Regular Examinations, April 2012


PRINCIPLES OF PROGRAMMING LANGUAGE
(Com. to CSE, IT)
Time: 3 hours

Max. Marks: 75
Answer any FIVE Questions
All Questions carry Equal Marks
~~~~~~~~~~~~~~~~~~~~~~

1.

a) Give the derivation and parse tree for expressions to generate the string slope * x +
intercept
b) List the principal phases of compilation, and describe the work performed by each.
(7M+8M)

2.

a) Why does the use of dynamic scoping imply the need for run-time type checking?
b) Consider the following pseudo code.
Procedure P (A, B: real)
X: real
Procedure Q (B, C: real)
Y: real
...
Procedure R (A, C: real)
Z: real
. . . (*)
...
Assuming static scope, what is the referencing environment at the location marked by (*)?
(7M+8M)

3.

a) Describe in detail about evaluating attributes for the expression(1 + 3)*2


b) Describe the similarities and differences between context-free grammars and tree grammars.
(7M+8M)

4.

a) Why is it generally expensive to catch all uses of uninitialized variables at run time? Why is
it impossible to catch all uses of uninitialized variables at compile time?
b) Describe the jump code implementation of short-circuit Boolean evaluation.

1 of 2

(7M+8M)

Code No: R22056

5.

R10

SET - 1

a) Explain the difference between type conversion, type coercion, and non-converting type
casts.
b) Discuss the significance of holes in records. Why do they arise? What problems do they
cause?

6.

(7M+8M)

a) What is the principal purpose of generics? In what sense do generics serve a broader purpose
in C++ and Ada than they do in Java and C#?
b) Describe in detail about implementing synchronization.

7.

(7M+8M)

a) Summarize visibility rules of C++. How do the rules for member name visibility in
Smalltalk and Objective-C differ from the rules of most other object-oriented languages?
b) Explain in detail about Shared and Replicated Inheritance with examples.

8.

(7M+8M)

a) Define Functional Programming Language. List the properties of Functional Programming


languages and describe each of them briefly.
b) Summarize Prologs facilities for database manipulation. Explain the usage of assert,
retract, and clause.

(7M+8M)

2 of 2

R10

Code No: R22056

SET - 2

II B.Tech II Semester, Regular Examinations, April 2012


PRINCIPLES OF PROGRAMMING LANGUAGE
(Com. to CSE, IT)
Time: 3 hours

Max. Marks: 75
Answer any FIVE Questions
All Questions carry Equal Marks
~~~~~~~~~~~~~~~~~~~~~~

1.

a) Describe the form in which a program is passed from the scanner to the parser; from the
parser to the semantic analyzer; from the semantic analyzer to the intermediate code generator.
b) Summarize the difference between LL and LR parsing. Which one of them is also called
bottom-up? Top-down? Which one is also called predictive? Shift reduce? What do
LL and LR stands for?

2.

(7M+8M)

a) What do we mean by the scope of a name-to-object binding? Explain about the closest
nested scope rule.
b) Explain the distinction between decisions that are bound statically and those that are bound
dynamically. What is the advantage of binding things as early as possible? What is the
advantage of delaying bindings?

3.

(7M+8M)

a) Why cant action routines be placed at arbitrary locations within the right hand side of
productions in an LR CFG?
b) Give the Attribute grammar to decorate an abstract syntax tree for the calculator language
with types.

4.

(7M+8M)

a) Explain the difference between prefix, infix, and postfix notation. What is Cambridge Polish
notation? Name two programming languages that use postfix notation.
b) Describe three different search strategies that might be employed in the implementation of a
case statement, and the circumstances in which each would be desirable.

1 of 2

(7M+8M)

Code No: R22056

5.

R10

SET - 2

a) Summarize the ways in which one dereferences a pointer in various programming


languages.
b) In what ways may an enumeration type be preferable to a collection of named constants? In
what ways may a sub range type be preferable to its base type? It what ways may a string be
preferable to an array of characters?

6.

(7M+8M)

a) Describe different parameter Modes in Ada .How do they differ from the modes of most
other Algol-family languages?
b) Describe the algorithm used to identify an appropriate handler when an exception is raised in
a language like Ada or C++.

7.

(7M+8M)

a) Compare Java final methods with C++ non-virtual methods. How are they the same? How
are they different?
b) What is a metaclass in Smalltalk? Explain the difference between initialization and
assignment in C++ with suitable examples.

8.

(7M+8M)

a) Why is the order of evaluation is essential in evaluating expressions? Explain in detail about
Strictness and Lazy Evaluation and I/O Streams.
b) Define Horn Clause with an example. What sorts of logical statements cannot be captured in
Horn clauses? Also describe the generate-and-test programming idiom.

2 of 2

(7M+8M)

SET - 3

R10

Code No: R22056

II B.Tech II Semester, Regular Examinations, April 2012


PRINCIPLES OF PROGRAMMING LANGUAGE
(Com. to CSE, IT)
Time: 3 hours

Max. Marks: 75
Answer any FIVE Questions
All Questions carry Equal Marks
~~~~~~~~~~~~~~~~~~~~~~

1.

a) Explain the distinction between interpretation and compilation. What are the comparative
advantages and disadvantages of the two approaches?
b) What does it mean for a context-free grammar to be ambiguous?

2.

(7M+8M)

a) Explain the distinction between the lifetime of a name-to-object binding and its visibility.
b) Why are binding rules particularly important for languages with dynamic scoping?(7M+8M)

3.

a) What does it mean for an attribute grammar to be S-attributed? L-attributed? Noncircular?


What is the significance of these grammar classes?
b) Describe in detail about the role of semantic analyzer.

4.

(7M+8M)

a) What is a tail-recursive function? Why is tail recursion important? Write a tail-recursive


function in Scheme or ML to compute n factorial n! = _1in i = 1 2

n). (Hint:

You will probably want to define a helper function)


b) Discuss in detail about problems with the Fortran IV do loop.

5.

(7M+8M)

a) Discuss the comparative advantages of structural and name equivalence for types. Name
three languages that use each approach.
b) Discuss the differences between the denotational, constructive, and abstraction-based views
of types.

(7M+8M)

1 of 2

Code No: R22056

6.

R10

SET - 3

a) What does it mean for a generic parameter to be constrained? Explain the difference between
explicit and implicit constraints. Why will C# accept int as a generic argument, but Java wont?
b) What is an exception? Explain how to implement exceptions in a way that incurs no cost in
the common case (when exceptions dont arise).

7.

(7M+8M)

a) Explain the difference between dynamic and static method binding (i.e., between virtual and
non-virtual methods).

(7M+8M)

b) Explain why in-line subroutines are particularly important in object-oriented languages.

8.

a) What is a higher-order function? Give three examples of higher order functions. Also
explain the concept of Currying in detail.
b) What mathematical formalism underlies logic programming? Briefly describe the process of
unification and resolution in logic programming.

2 of 2

(7M+8M)

Code No: R22056

R10

SET - 4

II B.Tech II Semester, Regular Examinations, April 2012


PRINCIPLES OF PROGRAMMING LANGUAGE
(Com. to CSE, IT)
Time: 3 hours

Max. Marks: 75
Answer any FIVE Questions
All Questions carry Equal Marks
~~~~~~~~~~~~~~~~~~~~~~

1.

a) What is the difference between a phase and a pass of compilation? Under what
circumstances does it make sense for a compiler to have multiple passes?
b) What is P-code and also discuss in detail about bootstrapping?

2.

(7M+8M)

a) Consider the following pseudo code, assuming nested subroutines and static scope.
Procedure main
g: integer
Procedure B(a : integer)
x: integer
Procedure A(n : integer)
g := n
Procedure R(m : integer)
write integer(x)
x /:= 2 integer division
if x > 1
R(m + 1)
else
A(m)
body of B
x := a a
R(1)
body of main
B(3)
write integer(g)
b) What does this program print?
Show the frames on the stack when A has just been called. For each frame, show the static and
dynamic links.
c) Explain how A finds g.
(5M+5M+5M)

1 of 2

Code No: R22056

3.

R10

SET - 4

a) What is an attribute grammar? What is the difference between synthesized and inherited
attributes?
b) What sort of information do action routines typically keep in global variables, rather than in
attributes?

4.

(7M+8M)

a) Explain about Structured Alternatives to goto in detail.


b) Describe three subtleties in the implementation of enumeration-controlled loops. Why do
most languages not allow the bounds or increment of an enumeration controlled loop to be
floating-point numbers?

5.

(7M+8M)

a) What does it mean for a language to be strongly typed? Statically typed? What prevents, say,
C from being strongly typed?
b) Discuss the type safety problems that arise with variant records. How can these problems be
addressed?

6.

(7M+8M)

a) Describe in detail about the calling sequence to maintain stack layout. Explain this with a
typical stack frame.
b) Describe three alternative means of allocating co-routine stacks. What are their relative
strengths and weaknesses?

7.

(7M+8M)

a) Describe how virtual functions can be used to achieve the effect of subroutine closures.
b) Describe in detail about data hiding in Euclid and Ada.

8.

(7M+8M)

a) Explain in detail how Control Flow and Assignment Expressions are defined in Scheme with
examples. Also discuss briefly on the concept of Program as Lists in Scheme.
b) What are clauses, terms, and structures in Prolog? What are facts, rules, and queries? Give
examples of each.

(7M+8M)

2 of 2

You might also like