JNTU

JNTU B.Tech II PRINCIPLES OF PROGRAMMING LANGUAGES Previous Question Paper (November/December - 2020 - R15)

B.Tech | II | II-II | R15 | November/December - 2020

Answer PaperPaper Code: 124DJMaximum Marks: 75Time: 2 hours

Answer any five questions. All questions carry equal marks.

Main

1

Explain about attribute grammar and ambiguous grammar with an example.

15 marks

Answer

An attribute grammar is a formal notation used to define the semantics of a programming language by augmenting a context-free grammar with attributes and semantic rules. It associates attributes with the grammar symbols and provides rules to compute these attributes, allowing for the description of context-sensitive features that standard context-free grammars cannot capture, such as type checking or scope resolution.

A semantic rule takes the form:

A -> B C { A.a = f(B.b, C.c) }
where the value of attribute 'a' of non-terminal 'A' is computed based on the attributes of its children 'B' and 'C'. Attributes are classified as synthesized (passing information up the parse tree) or inherited (passing information down or across the parse tree).

An ambiguous grammar is a context-free grammar for which there exists at least one string in the language that can be generated by more than one distinct parse tree or leftmost derivation. Ambiguity is problematic in programming languages because it leads to multiple interpretations of the same code structure, which can cause unpredictable behavior during compilation or execution.

A classic example of an ambiguous grammar is the dangling-else problem:

stmt -> if expr then stmt | if expr then stmt else stmt | other

In this grammar, the string

if E1 then if E2 then S1 else S2
is ambiguous because the 'else' clause can be associated with either the first 'if' or the second 'if'. To resolve such ambiguity, the grammar must be rewritten to force a specific association, typically by requiring that every 'else' matches the nearest preceding unmatched 'if' or by introducing explicit delimiters like 'endif'.

2

Explain binding and reference types with an example.

15 marks

Answer

Binding refers to the association between an entity (such as a variable, function, or type) and an attribute (such as its value, memory address, or data type). This association can occur at different times during the program lifecycle, known as binding time, which includes language design time, language implementation time, compile time, load time, or runtime.

Bindings are categorized as static if they occur before runtime and remain unchanged, or dynamic if they occur during execution or can change during the program's execution. For example, in C, the type of a variable is statically bound at compile time, whereas in Python, the type of a variable is dynamically bound to the type of the value assigned to it at runtime.

Reference types are data types that do not store the actual value directly but instead store a memory address (or reference) pointing to the location where the data resides. When a reference type is assigned to another variable, both variables point to the same memory location, meaning changes made through one variable are reflected in the other.

Example in Java:

// Reference type example
int[] arr1 = {1, 2, 3};
int[] arr2 = arr1; // Both variables point to the same array object in memory
arr2[0] = 99;
// Now arr1[0] is also 99, because they share the same reference

In this example, arr1 and arr2 are reference types. Unlike value types (like primitive integers), which copy the data itself, reference types facilitate efficient memory management and allow multiple parts of a program to share and modify the same data structure.

3

Explain about overloaded subprograms with an example.

15 marks

Answer

Sign in to view the complete answer paper.

4

Explain about exception handling in Ada with a suitable example.

15 marks

Answer

Sign in to view the complete answer paper.

5

Explain about functional programming language.

15 marks

Answer

Sign in to view the complete answer paper.

6

Explain about denotational and axiomatic semantics for common programming language.

15 marks

Answer

Sign in to view the complete answer paper.

7

Mention and explain about various expressions with a suitable example for each.

15 marks

Answer

Sign in to view the complete answer paper.

815 marks
a

Explain about design issues of functions.

8 marks

Answer

Sign in to view the complete answer paper.

b

Explain about coroutines.

7 marks

Answer

Sign in to view the complete answer paper.

About this paper

This page contains the question paper of PRINCIPLES OF PROGRAMMING LANGUAGES from JNTU for B.Tech IT II II-II, November/December - 2020, R15.

For the solved question paper with answers, switch to the Answer Paper tab.

Other papers in PRINCIPLES OF PROGRAMMING LANGUAGES

Loading Question Papers

Fetching data from database...