PRINCIPLES OF PROGRAMMING LANGUAGES (RCS-503)
B.Tech (SEM-V) – AKTU
SECTION A
(Attempt all questions – 2 × 7 = 14 marks)
Q1 (a) What are advantages and disadvantages of dynamic local variables?
Dynamic local variables are allocated memory during runtime and exist only while the function is active.
Their main advantage is efficient memory utilization because memory is released after function execution. They also support recursion effectively.
However, disadvantages include higher runtime overhead due to repeated allocation and deallocation and difficulty in debugging because variable lifetime is short.
Q1 (b) Explain lambda expression.
A lambda expression is an anonymous function that does not have a name and is used to define short pieces of code. It is commonly used in functional programming languages and modern languages like Python and Java. Lambda expressions improve code readability and reduce boilerplate code.
Q1 (c) Explain about parsing.
Parsing is the process of analyzing a sequence of tokens to determine its grammatical structure according to a formal grammar. It checks whether the syntax of a program is correct and builds a parse tree used by compilers for further processing.
Q1 (d) Define pass by result.
Pass by result is a parameter passing technique where the value of the formal parameter is copied back to the actual parameter after function execution. The initial value of the parameter is not used inside the function.
Q1 (e) Write any two design issues for arithmetic expressions.
Two design issues for arithmetic expressions are operator precedence and associativity. Operator precedence determines the order of evaluation, while associativity determines how operators of the same precedence are grouped.
Q1 (f) Explain fundamentals of functional programming language.
Functional programming is based on mathematical functions and avoids changing state or mutable data. It emphasizes recursion, higher-order functions, and immutability, leading to more reliable and predictable programs.
Q1 (g) What is an overriding method?
Method overriding occurs when a subclass provides a specific implementation of a method already defined in its parent class. It supports runtime polymorphism and improves flexibility in object-oriented programming.
SECTION B
(Attempt any three – 7 × 3 = 21 marks)
Q2 (a) Explain about static, fixed stack dynamic, fixed heap dynamic and dynamic variables.
Static variables are allocated at compile time and exist throughout program execution.
Fixed stack dynamic variables are allocated during function calls and deallocated when the function ends.
Fixed heap dynamic variables are allocated from heap memory but with fixed size.
Dynamic variables have size and lifetime determined at runtime and provide maximum flexibility.
Q2 (b) Write notes on coercion expressions and short-circuit evaluation.
Coercion expressions involve implicit type conversion during expression evaluation, such as converting integers to floating-point numbers.
Short-circuit evaluation stops expression evaluation as soon as the result is known, improving efficiency and preventing unnecessary computations.
Q2 (c) Write differences between procedural and non-procedural languages.
Procedural languages focus on step-by-step instructions and use functions and procedures to structure programs.
Non-procedural languages focus on what result is required rather than how it is achieved and are commonly used in declarative programming.
SECTION C
(Attempt any one – 7 × 1 = 7 marks)
Q3 (e) What is an event? How are events handled in various OOP languages?
An event is an action or occurrence detected by a program, such as mouse clicks or key presses.
In object-oriented languages, events are handled using event listeners or handlers. Java uses event listener interfaces, C# uses delegates and events, while Python handles events using callback functions. Event-driven programming improves interactivity and responsiveness of applications.