0% found this document useful (0 votes)
10 views

PPL Question Bank

The document outlines the syllabus for the Principles of Programming Languages course at Theni Kammavar Sangam College of Technology, covering various topics in programming language principles, syntax, semantics, parsing, and type checking. It includes detailed questions and exercises for both Part A and Part B of each unit, emphasizing practical understanding and application of programming concepts. The course aims to provide a comprehensive understanding of programming languages and their underlying principles.

Uploaded by

mvishnushankari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

PPL Question Bank

The document outlines the syllabus for the Principles of Programming Languages course at Theni Kammavar Sangam College of Technology, covering various topics in programming language principles, syntax, semantics, parsing, and type checking. It includes detailed questions and exercises for both Part A and Part B of each unit, emphasizing practical understanding and application of programming concepts. The course aims to provide a comprehensive understanding of programming languages and their underlying principles.

Uploaded by

mvishnushankari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

THENI KAMMAVAR SANGAM COLLEGE OF TECHNOLOGY

KODUVILARPATTI, THENI – 625534


DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

CCS358 PRINCIPLES OF PROGRAMMING LANGUAGES

UNIT I
PART A
1. Define syntax and semantics.
2. Explain the scope and life time of a variable.
3. Identify lexeme and tokens in the following statement: value=count*3+20.
4. What does a linker do?
5. What are the different ways to define languages?
6. State the need for scope rule.
7. Define attribute grammar.
8. Differentiate between syntax and semantics by an example.
9. Write down a BNF grammar for the language composed of all binary numbers that
contain at least three consecutive 1’s.
10. What role does the symbol table play in a compiler?
11. What do you mean by type coercion?
12. What is an alias? What are the problems associated with it?
13. Define declarative semantics.
14. Describe briefly the three approaches to building a lexical analyzer.
15. Write BNF notation for ‘do-while’ loop.
16. Define CFG. What does it mean for CFG to be ambiguous?
17. Explain syntax of 'for' statement in PASCAL using BNF notation and syntax graphs.
18. Describe differences between Top-Down and Bottom-Up Parsers.
19. What is the difference between an intrinsic attribute and a nonintrinsic synthesized
attribute?
20. Write an EBNF rule that describes the ‘while’ statement of Java or C++. Write the
recursive-descent subprogram in Java or C++ for this rule.
21. Write an EBNF rule that describes the ‘for’ statement of Java or C++. Write the
recursive-descent subprogram in Java or C++ for this rule.
22. Using the following grammar show a parse tree and a leftmost derivation for the
following statement: A=A*(B+(C*A))
<assign>  <id> = <expr>
<id>  A|B|C
<expr>  <id> + <expr> | <id> + <expr> | (<expr>) | <id>
23. Write an EBNF rule that describe the while statement of Java or C++.
24. Write the recursive descent subprogram in Java or C++ for this rule.
25. Prove that the following grammar is ambiguous:
<S> → <A>
<A> → <A> + <A> | <id>
<id> → a | b | c
26. Describe, in English, the language defined by the following grammar:
<S> → <A> <B> <C>
<A> → a <A> | a
<B> → b <B> | b
<C> → c <C> | c
PART B
1. Discuss about the formal methods for describing syntax.
2. What is parsing? What are the different types of parser available? Discuss.
3. What are the different types of binding available? Explain with an example.
4. Give a brief on historical development of programming language?
5. Briefly present milestones in the evolution of programming languages.
6. Demonstrate the functionality of lexical analysis.
7. Write the recursive procedures for any grammar using recursive descent parser with
example. List out the limitations of it.
8. Compute the weakest precondition for each of the following assignment statements and
postconditions:
a. a = 2 * (b - 1) - 1 {a > 0}
b. b = (c + 10) / 3 {b > 6}
c. a = a + 2 * b - 1 {a > 1}
d. x = 2 * y + x - 1 {x > 11}
9. Write a denotational semantics mapping function for the following statements:
a. Ada for
b. Java do-while
c. Java Boolean expressions
d. Java for
e. C switch
10. Write EBNF descriptions for the following:
a. A Java class definition header statement
b. A Java method call statement
c. A C switch statement
d. A C union definition
e. C float literals

UNIT II
PART A
1. What are the differences between enumeration types of C++ and Java?
2. What is the problem with case sensitive names?
3. What are the design issues for names?
4. What is the potential danger of case-sensitive names?
5. In what way are reserved words better than keywords?
6. What is an alias?
7. Define Associative Array? Explain its uses.
8. Define operator precedence and operator associativity.
9. Define functional side effect.
10. What is the l-value of a variable? What is the r-value?
11. Define binding and binding time.
12. What is the l-value and r-value of a variable?
13. Define functional side effect.
14. What is a dangling pointer?
15. What is type checking? Explain the advantages and disadvantages of static and dynamic
type checking.
16. Write about static variables, stack dynamic variables and heap dynamic variables.
17. Define Type error, Type checking and Strong Typing.
18. Differentiate between static type checking and dynamic type checking and give their
relative advantages.
19. Define narrowing and widening conversions.
20. Type conversion provides more flexibility to the user. Comment on it?
21. Illustrate the difference between primitive data types and derived data types.
22. What mixed-mode assignments are allowed in C and Java?
23. Give the parse tree of a following statement: A = (B+C) * (D / E).
24. What are the advantages and disadvantages of implicit declarations?
25. What are the advantages and disadvantages of dynamic type binding?
26. Define static, stack-dynamic, explicit heap-dynamic, and implicit heap-dynamic
variables. What are their advantages and disadvantages?
27. Define lifetime, scope, static scope, and dynamic scope.
28. What is the general problem with static scoping?
29. What is the referencing environment of a statement?
30. What are the design issues for character string types?
31. How does JavaScript support sparse arrays?
32. 12. What languages support negative subscripts?
33. 13. What languages support array slices with stepsizes?
34. What languages have no type coercions?
35. What is the definition of control structure?
36. What is the definition of block?
PART B
1. Explain type checking technique in parameter passing?
2. Explain about static, fixed stack dynamic, dynamic and heap dynamic arrays.
3. Explain about the preconditions and post conditions of a given statement mean in
axiomatic semantics.
4. Explain the significance of this parameter in object oriented languages?
5. Define union. What is the difference between record and union? Explain how union is
supported by different programming languages?
6. What are the four types of bindings can take place in a program? Explain with examples.
7. Define a pointer. Explain various design issues of pointers in C/C++.
8. Consider the following records of a particular language. Let the size of each char
variable be 1 byte, int variable be 4 bytes and double be 8 bytes.
1) struct employee
{
char name[2];
int age;
double mark;
}
2) union employee
{
char name[2];
int age;
double mark;
}
Draw the memory layout for the records (1) and (2)
9. Explain Logically Controlled Loop with suitable examples.
10. Analyze and write a comparison of using C++ pointers and Java reference variables to
refer to fixed heap-dynamic variables. Use safety and convenience as the primary
considerations in the comparison.
11. Analyse and write a comparison of using C++ pointer and Java reference variables to
refer to fixed heap-dynamic variables. Use safety and convenience as the porimary
considerations in the comparison.
12. Compare the string manipulation capabilities of the class libraries of C++, Java, and
C#.
13. Describe three programming situations that require a posttest loop.
14. Write short notes on 1. Associative array. 2. Pointers and reference types. 3.
Overloading Operators. 4. Type conversion
15. Write a simple assignment statement with one arithmetic operator in some language
you know. For each component of the statement, list the various bindings that are
required to determine the semantics when the statement is executed. For each binding,
indicate the binding time used for the language.
16. Explain in detail about Guarded commands.
17. Assume the following rules of associativity and precedence for expressions:
Precedence Highest
*, /, not
+, –, &, mod
– (unary)
=, /=, < , <=, >=, >
and
Lowest
or, xor
Associativity Left to right
Show the order of evaluation of the following expressions by parenthesizing all
subexpressions and placing a superscript on the right parenthesis to indicate order. For
example, for the expression a + b * c + d the order of evaluation would be represented
as
((a + (b * c))+ d)
a. a * b - 1 + c
b. a * (b - 1) / c mod d
c. (a - b) / c & (d * e / a - 3)
d. -a or c = d and e
e. a > b xor c or d <= 17
f. -a + b
18. Consider the following JavaScript skeletal program:
// The main program
var x;
function sub1() {
var x;
function sub2() {
...
}
}
function sub3() {
...
}
Assume that the execution of this program is in the following unit order:
main calls sub1
sub1 calls sub2
sub2 calls sub3
a. Assuming static scoping, in the following, which declaration
of x is the correct one for a reference to x?
i. sub1
ii. sub2
iii. sub3
b. Repeat part a, but assume dynamic scoping.
UNIT III
PART A
1. Write down the design issues of functions.
2. What are the fundamental design considerations for parameter passing methods?
3. Explain Procedural abstraction in the case of C?
4. List the design issues of subprogram.
5. What is the difference between an activation record and an activation record instance?
6. What are the three general characteristics of subprograms?
7. What does it mean for a subprogram to be active?
8. What is given in the header of a subprogram?
9. What characteristic of Python subprograms sets them apart from those of other
languages?
10. What languages allow a variable number of parameters?
11. What is a parameter profile? What is a subprogram protocol?
12. What are formal parameters? What are actual parameters?
13. What are the advantages and disadvantages of keyword parameters?
14. What are the differences between a function and a procedure?
15. What are the design issues for subprograms?
16. What are the advantages and disadvantages of dynamic local variables?
17. What languages allow subprogram definitions to be nested?
18. What are the three semantic models of parameter passing?
19. Describe the ways that aliases can occur with pass-by-reference parameters.
20. What is an overloaded subprogram?
21. What is parametric polymorphism?
22. What causes a C++ template function to be instantiated?
23. Define shallow and deep binding for referencing environments of subprograms that
have been passed as parameters.
24. What are the two reasons why implementing subprograms with stack-dynamic local
variables is more difficult than implementing simple subprograms?
25. What is the difference between an activation record and an activation record instance?
26. Why are the return address, dynamic link, and parameters placed in the bottom of the
activation record?
27. What are the two steps in locating a nonlocal variable in a static-scoped language with
stack-dynamic local variables and nested subprograms?
28. Define static chain, static_depth, nesting_depth, and chain_offset.
29. What is an EP, and what is its purpose?
30. How are references to variables represented in the static-chain method?
31. Name three widely used programming languages that do not allow nested subprograms.
32. What are the two potential problems with the static-chain method?
33. Explain the two methods of implementing blocks.
34. Describe the deep-access method of implementing dynamic scoping.
35. Describe the shallow-access method of implementing dynamic scoping.
36. What are the two differences between the deep-access method for nonlocal access in
dynamic-scoped languages and the static-chain method for static-scoped languages?
37. Compare the efficiency of the deep-access method to that of the shallow access method,
in terms of both calls and nonlocal accesses.
PART B
1. Explain with examples pass- by- value and pass- by- reference parameter passing
techniques?
2. Explain co-routine? Why cactus-stack is used in co-routine? Distinguish from
subroutine?
3. Write a short note on
i. Subroutine
ii. Generic subprogram in Java
iii. Co-routines
4. Show the stack with all activation record instances, including static and dynamic chains,
when execution reaches position 1 in the following skeletal program.
Assume Bigsub is at level 1.
Procedure Bigsub is
Procedure A is
Procedure B is
Begin .. of B
…1
End; --of B
Procedure C is
Begin .. of C
…1
B;

End; --of C
Procedure A is
Begin .. of A
…1
C;
..
End; --of A
Begin .. of Bigsub

A;

End; -- of Bigssub

5. Design a skeletal program and a calling sequence that results in an activation record
instance in which the static and dynamic links point to different activation – recorded
instances in the run-time stack.
6. Can a user access a non-local object in case of subroutines? Give valid reasons.
7. Explain co-routine? Why cactus-stack is used in co-routine? Distinguish from
subroutine?
8. Examine the subprogram call instructions of three different architectures, including at
least one CISC machine and one RISC machine, and write a short comparison of their
capabilities. (The design of these instructions usually determines at least part of the
compiler writer’s design of subprogram linkage.)
9. The static-chain method could be expanded slightly by using two static links in each
activation record instance where the second points to the static grandparent activation
record instance. How would this approach affect the time required for subprogram
linkage and nonlocal references?
10. Consider the following program written in C syntax:
void swap(int a, int b) {
int temp;
temp = a;
a = b;
b = temp;
}
void main() {
int value = 2, list[5] = {1, 3, 5, 7, 9};
swap(value, list[0]);
swap(list[0], list[1]);
swap(value, list[value]);
}
For each of the following parameter-passing methods, what are all of the
values of the variables value and list after each of the three calls to
swap?
a. Passed by value
b. Passed by reference
c. Passed by value-result

UNIT IV
PART A
1. What is the difference between a class variable and an instance variable?
2. When do you prefer binary semaphores over counting semaphores?
3. What is Object oriented programming? What are its key concepts?
4. Write short note on Dynamic Method Binding of object oriented languages.
5. Consider the following program
class student: public person, public gp_list_node {…
6. Explain the type of inheritance is used in this program?
7. Write a short note on constructors.
8. Define abstract data type.
9. What are the language design issues for abstract data types?
10. From where are C++ objects allocated?
11. What is the purpose of a C++ constructor?
12. How are C++ class instances created?
13. What is a friend function? What is a friend class?
14. How can an exception be explicitly raised in Ada?
15. Can a user access a non-local object in case of subroutines? Give valid reasons.
16. Can a reference variable be designed for an abstract class? Explain.
17. Why are destructors rarely used in Java but essential in C++?
18. What are the disadvantages of designing an abstract data type to be a pointer?
19. Describe the three characteristic features of object-oriented languages.
20. What is the difference between a class variable and an instance variable?
21. What is multiple inheritance?
22. What is a polymorphic variable?
23. What is an overriding method?
24. Describe a situation where dynamic binding is a great advantage over its absence.
25. What is a virtual method?
26. What is a pure virtual function in C++?
27. How are parameters sent to a superclass’s constructor in C++?
28. What is an abstract method? What is an abstract class?
29. Describe briefly the eight design issues used in this chapter for object oriented
languages.
30. What is a nesting class?
31. From where can Java objects be allocated?
32. What is boxing?
33. How are Java objects deallocated?
34. Are all Java subclasses subtypes?
35. How are superclass constructors called in Java?
36. What is the message protocol of an object?
37. Explain the basic concepts of exception handling?
38. What is a multithreaded program?
39. Compare the dynamic binding of C++ and Java.
40. What is the difference between physical and logical concurrency?
41. What are the differences between a C++ abstract class and a Java interface?
42. What are the three possible levels of concurrency in programs?
43. Compare the class entity access controls of C++ and Java.
44. Define task, synchronization, competition and cooperation synchronization, liveness,
race condition, and deadlock.
45. Describe the actions of the wait and release operations for semaphores.
46. What is a binary semaphore? What is a counting semaphore?
47. What advantage do monitors have over semaphores?
48. Describe the actions of the three Java methods that are used to support cooperation
synchronization.
49. What kind of Java object is a monitor?
50. On what language is Multilisp based?
51. How can exceptions be explicitly raised in C++?
52. How are exceptions bound to handlers in C++?
53. Define rendezvous, accept clause, entry clause, actor task, server task, extended accept
clause, open accept clause, closed accept clause, and completed task.
54. What are the primary problems with using semaphores to provide synchronization?
55. What are the two primary design issues for language support for concurrency?
56. What are the design issues for exception handling?
57. What is the root class of all Java exception classes?
58. Can you disable a Java exception?
59. Define exception, exception handler, raising an exception, disabling an exception,
continuation, finalization, and built-in exception.
60. Explain Procedural abstraction, Generic abstraction &Data abstraction in C++?
61. Explain Procedural abstraction, Generic abstraction &Data abstraction in ADA?
62. Explain the following terms: (a) Message passing (b) Concurrency in Ada (c) Monitors.
63. Explain Procedural abstraction, Generic abstraction &Data abstraction in JAVA?

PART B
1. Write short notes on 1. Semaphores 2. Threads 3. Statement level concurrency 4.
Design issues of OOP.
2. Design a queue abstract data type for float elements in a language that you know,
including operations for enqueue, dequeue, and empty. The dequeue operation removes
the element and returns its value.
3. Compare the multiple inheritance of C++ with that provided by interfaces in Java.
4. Discuss the various design issues for object oriented programming languages.
5. Explain the cooperation synchronization using shared buffer for implementing
producer consumer problem.
The reader writer problem can be stated as follows: A shared memory location can be
concurrently read by any number of tasks, but when a task must write to the shared
memory location, it must have exclusive access. Write a Java program for the reader-
writer problem.
With the help of a neat diagram, explain activation record.
6. Explain the working principles of threads. With a neat diagram show the architecture
of thread?
7. Describe the issue of how closely the parameters of an overriding method must match
those of the method it overrides.
8. Write an abstract data type for complex numbers, including operations for addition,
subtraction, multiplication, division, extraction of each of the parts of a complex
number, and construction of a complex number from two floating-point constants,
variables, or expressions. Use Ada, C++, Java, C#, or Ruby.
9. The designers of Java obviously thought it was not worth the additional efficiency of
allowing any method to be statically bound, as is the case with C++. What are the
arguments for and against the Java design?
10. Explain why allowing a class to implement multiple interfaces in Java and C# does not
create the same problems that multiple inheritance in C++ creates.
11. Design and implement a C++ program that defines a base class A, which has a subclass
B, which itself has a subclass C. The A class must implement a method, which is
overridden in both B and C. You must also write a test class that instantiates A, B, and
C and includes three calls to the method. One of the calls must be statically bound to
A’s method. One call must be dynamically bound to B’s method, and one must be
dynamically bound to C’s method.
12. In languages without exception-handling facilities, it is common to have most
subprograms include an “error” parameter, which can be set to some value representing
“OK” or some other value representing “error in procedure.” What advantage does a
linguistic exception-handling facility like that of Ada have over this method?
13. Explain clearly why competition synchronization is not a problem in a programming
environment that supports coroutines but not concurrency.
14. Write a program in C++ that calls both a dynamically bound method and a statically
bound method a large number of times, timing the calls to both of the two. Compare
the timing results and compute the difference of the time required by the two. Explain
the results.
15. Suppose two tasks, A and B, must use the shared variable Buf_Size. Task A adds 2 to
Buf_Size, and task B subtracts 1 from it. Assume that such arithmetic operations are
done by the three-step process of fetching the current value, performing the arithmetic,
and putting the new value back. In the absence of competition synchronization, what
sequences of events are possible and what values result from these operations? Assume
that the initial value of Buf_Size is 6.
16. Consider the following C++ skeletal program:
class Big {
int i;
float f;
void fun1() throw int {
...
try {
...
throw i;
...
throw f;
...
}
catch(float) { . . . }
...
}
}
class Small {
int j;
float g;
void fun2() throw float {
...
try {
...
try {
Big.fun1();
...
throw j;
...
throw g;
...
}
catch(int) { . . . }
...
}
catch(float) { . . . }
}
}
In each of the four throw statements, where is the exception handled?
Note that fun1 is called from fun2 in class Small.

UNIT V
PART A
1. What does a lambda expression specify?
2. Define functional form, simple list, bound variable, and referential transparency.
3. What are two ways that ML is fundamentally different from schemes?
4. Explain database manipulation and searching strategies used in Prolog.
5. Give an overview of Scheme with suitable examples .Write its applications?
6. What are the key concepts of logic programming?
7. Describe the actions of the ML filter function.
8. Write a scheme function that takes a simple list of numbers as its parameter and returns
the largest and smallest numbers in the list.
9. Explain the two approaches for matching goals to facts in a database.
10. What does a lambda function specify?
11. What are antecedents and consequents?
12. What features of PROLOG classify it as a logic programming language?
13. Explain Assertions and clauses in PROLOG?
14. Explain the applications of functional programming languages.
15. How data abstraction is done in PYTHON?
16. What is Imperative programming? What are its key concepts?
17. Explain the closed world assumption used by prolog. Why is this a limitation?
18. How can a variable be universally quantified or existentially quantified?
19. Write the different classes of exceptions in java.
20. What is monitor? What are the advantages and disadvantages over semaphores?
21. What is exception handling? How can we handle exception in C++. Give example.
22. Write down the basic elements of Prolog. Also give the applications of logic
programming.
23. Explain database manipulation and searching strategies used in Prolog.
24. Give an overview of Scheme with suitable examples .Write its applications?
25. What type of referencing as used in ML?
26. What data types were parts of the original LISP?
27. In what common data structure are LISP lists normally stored?
28. Why were imperative features added to most dialects of LISP?
29. In what ways are Common LISP and Scheme opposites?
30. What scoping rule is used in Scheme? In Common LISP? In ML? In Haskell? In F#?
31. Describe the actions of the ML filter function.
32. What are the three characteristics of Haskell that make it different from ML?
33. What is a strict programming language?
PART B
1. Find at least one example of a typed functional programming language being used to
build a commercial system in each of the following areas: database processing, financial
modeling, statistical analysis, and bio-informatics.
2. Make a list of the features of F# that are not in ML.
3. What does the following Scheme function do?
(define (y s lis)
(cond
((null? lis) '() )
((equal? s (car lis)) lis)
(else (y s (cdr lis)))
))
4. What does the following Scheme function do?
(define (x lis)
(cond
((null? lis) 0)
((not (list? (car lis)))
(cond
((eq? (car lis) #f) (x (cdr lis)))
(else (+ 1 (x (cdr lis))))))
(else (+ (x (car lis)) (x (cdr lis))))
5. Write a Scheme function that computes the real roots of a given quadratic equation. If
the roots are complex, the function must display a message indicating that. This
function must use an IF function. The three parameters to the function are the three
coefficients of the quadratic equation.
6. Explain why Prolog systems must do backtracking.
7. Explain two ways in which the list-processing capabilities of Scheme and Prolog are
similar.
8. Write a Prolog program that returns a list containing the union of the elements of two
given lists.
9. Write a Prolog program that implements quicksort.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy