• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Principles of Programming Languages

Question 1

Consider the program given below, in a block-structured pseudo-language with lexical scoping and nesting of procedures permitted.
Program main;
  Var ...
  
    Procedure A1;
     Var ...
     Call A2;
    End A1
    
    Procedure A2;
      Var ...
  
      Procedure A21;
        Var ...
        Call A1;
        End A21
        
    Call A21;
  End A21
  
    Call A1;
  End main.

Consider the calling chain : Main->A1->A2->A21->A1 The correct set of activation records along with their access links is given by : gatecs2012activationrecord gatecs2012activationrecord
  • A
  • B
  • C
  • D

Question 2

Which languages necessarily need heap allocation in the runtime environment?
  • Those that support recursion
  • Those that use dynamic scoping
  • Those that allow dynamic data structures
  • Those that use global variables

Question 3

Which of the following are true?
I. A programming language which does not permit global variables of any
   kind and has no nesting of procedures/functions, but permits recursion 
   can be implemented with static storage allocation
II. Multi-level access link (or display) arrangement is needed to arrange 
    activation records only if the programming language being implemented 
    has nesting of procedures/functions
III. Recursion in programming languages cannot be implemented with dynamic 
     storage allocation
IV. Nesting of procedures/functions and recursion require a dynamic heap 
    allocation scheme and cannot be implemented with a stack-based allocation
    scheme for activation records
V. Programming languages which permit a function to return a function as its 
   result cannot be implemented with a stack-based storage allocation scheme 
   for activation records
  • II and V only
  • I, III and IV only
  • I, II and V only
  • II, III and V only

Question 4

Which one of the following is NOT performed during compilation?
  • Dynamic memory allocation
  • Type checking
  • Symbol table management
  • Inline expansion

Question 5

Which of the following statements are CORRECT?
1) Static allocation of all data areas by a compiler
   makes it impossible to implement recursion.
2) Automatic garbage collection is essential 
   to implement recursion.
3) Dynamic allocation of activation records is 
   essential to implement recursion.
4) Both heap and stack are essential to implement
   recursion.
  • 1 and 2 only
  • 2 and 3 only
  • 3 and 4 only
  • 1 and 3 only

Question 6

Consider the following code written in a pass-by-reference language like FORTRAN and these statements about the code.
subroutine swap(ix,iy)
     it = ix
L1 : ix = iy
L2 : iy = it
end
  ia = 3
  ib = 8
  call swap (ia, 1b+5)
  print *, ia, ib
end 
S1: The compiler will generate code to allocate a temporary nameless cell, initialize it to 13, and pass the address of the cell swap S2: On execution the code will generate a runtime error on line L1 S3: On execution the code will generate a runtime error on line L2 S4: The program will print 13 and 8 S5: The program will print 13 and -2 Exactly the following set of statement(s) is correct:
  • S1 and S2
  • S1 and S4
  • S3
  • S1 and S5

Question 7

A common property of logic programming languages and functional languages is:

  • both are procedural languages

  • both are based on λ-calculus

  • both are declarative

  • both use Horn-clauses

Question 8

The goal of structured programming is to:
  • have well indented programs
  • be able to infer the flow of control from the compiled code
  • be able to infer the flow of control from the program text
  • avoid the use of GOTO statements

Question 9

Choose the best matching between the programming styles in Group 1 and their characteristics in Group 2.
 Group-1  Group-2
 P.  Functional  1.  Command-based, proce-dural
 Q.  Logic  2.  Imperative, abstract data type
 R.  Object-oriented  3.  Side-effect free, declarative, expression evaluation
 S.  Imperative  4.  Declarative, clausal representation, theorem proving
  • P-2, Q-3, R-4, S-1
  • P-4, Q-3, R-2, S-1
  • P-3, Q-4, R-1, S-2
  • P-3, Q-4, R-2, S-1

Question 10

Which of the following statements is FALSE ?
  • In statically typed language, each variable in a program has a fixed type
  • In un-typed languages, values do not have any types
  • In dynamically typed languages, variables have no types
  • In all statically typed languages, each variable in a program is associated with values of only a single type during the execution of the program

There are 35 questions to complete.

Last Updated :
Take a part in the ongoing discussion