JNTU
JNTU B.Tech II PRINCIPLES OF PROGRAMMING LANGUAGES Previous Question Paper (November/December - 2020 - R15)
Answer any five questions. All questions carry equal marks.
Main
Explain about attribute grammar and ambiguous grammar with an example.
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:
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:
In this grammar, the string
Explain binding and reference types with an example.
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:
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.
Explain about overloaded subprograms with an example.
Answer
Sign in to view the complete answer paper.
Explain about exception handling in Ada with a suitable example.
Answer
Sign in to view the complete answer paper.
Explain about functional programming language.
Answer
Sign in to view the complete answer paper.
Explain about denotational and axiomatic semantics for common programming language.
Answer
Sign in to view the complete answer paper.
Mention and explain about various expressions with a suitable example for each.
Answer
Sign in to view the complete answer paper.
Explain about design issues of functions.
Answer
Sign in to view the complete answer paper.
Explain about coroutines.
Answer
Sign in to view the complete answer paper.