JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD

JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD B. Tech III PRINCIPLES OF PROGRAMMING LANGUAGES Previous Question Paper (October - 2020 - R13)

B. Tech | III | I | R13 | October - 2020

Answer PaperPaper Code: 115ANMaximum Marks: 75Time: 2 hours

Answer any five questions. All questions carry equal marks.

Main

115 marks
a

Give an unambiguous grammar for if-then-else.

7 marks

Answer

The dangling else problem arises in standard grammars because an else clause can be associated with multiple if statements. To resolve this, we must distinguish between matched statements (those where every if has a corresponding else) and unmatched statements. An unambiguous grammar is defined as follows:

Stmt → MatchedStmt | UnmatchedStmt
MatchedStmt → if Expr then MatchedStmt else MatchedStmt | OtherStmt
UnmatchedStmt → if Expr then Stmt | if Expr then MatchedStmt else UnmatchedStmt

In this grammar, an unmatched statement cannot appear before an else clause, forcing the else to bind to the closest preceding if statement.

b

Explain in detail about various language implementation methods.

8 marks

Answer

Language implementation methods define how source code is transformed into executable machine code. The three primary methods are:

  • Compilation: The source program is translated into machine code by a compiler. The resulting object code is executed directly by the hardware. This approach offers high execution speed but requires a separate compilation step before execution.
  • Pure Interpretation: The source program is executed by an interpreter, which acts as a software simulation of a computer. The interpreter fetches, decodes, and executes instructions one by one. This allows for easy debugging and platform independence but is significantly slower than compiled code.
  • Hybrid Implementation: This method translates high-level source code into an intermediate language (e.g., bytecode), which is then interpreted by a virtual machine. This provides a balance between the portability of interpretation and the efficiency of compilation. Examples include Java (JVM) and Python.
215 marks
a

Compute the weakest precondition for the following sequences of assignment statements and their post conditions:

a = 2 * b + 1;
b = a - 3
{ b < 0 }
7 marks

Answer

Sign in to view the complete answer paper.

b

Differentiate between functional and imperative languages.

8 marks

Answer

Sign in to view the complete answer paper.

315 marks
a

Discuss different data types in different programming languages.

7 marks

Answer

Sign in to view the complete answer paper.

b

Differentiate between pointers and reference types with examples.

8 marks

Answer

Sign in to view the complete answer paper.

415 marks
a

Explain the problems associated with Unconditional Branching.

7 marks

Answer

Sign in to view the complete answer paper.

b

Describe the process of Array initialization.

8 marks

Answer

Sign in to view the complete answer paper.

515 marks
a

Describe the problem of passing multi-dimensioned arrays as parameters. Explain with examples.

7 marks

Answer

Sign in to view the complete answer paper.

b

In what fundamental ways do the generic parameters to a Java 5.0 generic method differ from those of C++ methods?

8 marks

Answer

Sign in to view the complete answer paper.

615 marks
a

What are the design issues for subprograms? What are the differences between a function and a procedure?

7 marks

Answer

Sign in to view the complete answer paper.

b

What languages allow the user to overload operators? Give examples.

8 marks

Answer

Sign in to view the complete answer paper.

715 marks
a

How are instances of Ada generic classes and C++ template classes created? Explain with examples.

7 marks

Answer

Sign in to view the complete answer paper.

b

How can exceptions explicitly raised in C++? Explain with an example.

8 marks

Answer

Sign in to view the complete answer paper.

815 marks
a

What is the difference between an ML val statement and an assignment statement in C?

7 marks

Answer

Sign in to view the complete answer paper.

b

How exceptions are handled in Python?

8 marks

Answer

Sign in to view the complete answer paper.

About this paper

This page contains the solved question paper with answers of PRINCIPLES OF PROGRAMMING LANGUAGES from JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD for B. Tech CSE III I, October - 2020, R13.

For the question paper without answers, switch to the Question Paper tab.

Other papers in PRINCIPLES OF PROGRAMMING LANGUAGES

Loading Question Papers

Fetching data from database...