Principles of Programming Languages Interview Questions & Answers

Principles of Programming Languages Interview Questions

Are you a Software developer, looking out to work on Programming Languages? If yes, then you can find thousands of job postings on the wisdomjobs page. Software development is a dynamic field where new frameworks, programming languages and new technologies are introduced frequently. So as a software developer you will have to constantly update yourself and learn new skills which are required for the job. Wisdomjobs will not only show the job vacancies available in your field, but will also prepare you to make your career prospects better. You can update yourself and be prepared to climb up the ladder in a reputed organization. At wisdomjobs we prepare you for the interview by giving you notes on Principles of Programming Languages job interview questions and answers. Read them thoroughly and crack your job hunt confidently.

Principles Of Programming Languages Interview Questions And Answers

Principles of Programming Languages Interview Questions
    1. Question 1. What Is Principle Of Programming Language?

      Answer :

      It is a set of rules governed to communicate instructions to a machine, particularly a computer.

    2. Question 2. What Are Objectives Of Principles Of Programming Language?

      Answer :

      Objectives are:

      • To introduce several different paradigms of programming
      • To gain experience with these paradigms by using example programming languages
      • To understand concepts of syntax, translation, abstraction, and implementation

    3. Question 3. What Are The Paradigms Of Programming?

      Answer :

      Several paradigms are-

      • Procedural
        examples: C, Pascal, Basic, Fortran
      • Functional
        examples: Lisp, ML
      • Object-oriented
        examples: C++, Java, Smalltalk
      • Rule-based (or Logic)
        example: Prolog

    4. Question 4. Why There Is Need Of So Many Paradigms?

      Answer :

      The choice of paradigm and therefore language depends on how human’s best think about the problem.

      Other considerations are:

      • Efficiency
      • Compatibility with existing code
      • Availability of translators

    5. Question 5. List The Models Of Computation Of Language?

      Answer :

      Models are:

      • RAM machine
      • Directed acyclic graphs
        Smalltalk model of O-O
      • Partial recursive functions
        Lisp and ML
      • Markov algorithms
        Prolog is loosely based on these

    6. Question 6. List Various Type Of Languages?

      Answer :

      Various types of languages are-

      • Document languages, e.g. LaTeX, Postscript
      • Command languages, e.g. bash, MATLAB
      • Markup languages, e.g. HTML and XML
      • Specification languages, e.g. UML

    7. Question 7. What Are The Issues For Languages?

      Answer :

      Issues are-

      • Can it be understood by people and processed by machines?
        Although translation may be required.
      • Sufficient expressive power?
        Can we say what needs to be said, at an appropriate level of abstraction?

    8. Question 8. What Is Translation?

      Answer :

      Translation is communication of converting the source code into target code.

    9. Question 9. What Are Different Types Of Translation And Their Roles?

      Answer :

      Types of translation are:

      • Compilation
        – Translate instructions into suitable (lower level) machine code
        – During execution, machine maintains program state information
      • Interpretation
        – May involve some translation
        – Interpreter maintains program state

    10. Question 10. What Is Trade’s Off Of Translation?

      Answer :

      Trade’s off of translation are:

      • • Compilation
        – lower level machine may be faster, so programs run faster
        – compilation can be expensive
        – examples: C
      • • Interpretation
        – more ability to perform diagnostics (or changes) at run-time
        – examples: Basic, UNIX shells, Lisp

    11. Question 11. What Is Parse Tree?

      Answer :

      A parse tree or parsing tree or derivation tree or concrete syntax tree is an ordered, rooted tree that represents the syntactic structure of a string according to some context-free grammar.

    12. Question 12. What Is Von-neumann Architecture?

      Answer :

      The Von-Neumann architecture, which is the basis for Turing machines, is based on the idea of stored and changing states. The operational semantics of a program is given by a sequence of systemstates (configurations).

    13. Question 13. What Is Backus-naur Form (bnf)?

      Answer :

      In computer science, Backus-Naur Form (BNF) is a metasyntax used to express context-free grammars: that is, a formal way to describe formal languages. John Backus and Peter Naur developed a context free grammar to define the syntax of a programming language by using two sets of rules: i.e., lexical rules and syntactic rules.

      BNF is widely used as a notation for the grammars of computer programming languages, instruction sets and communication protocols, as well as a notation for representing parts of natural language grammars.

    14. Question 14. What Is Type Checking/inference?

      Answer :

      Most programming languages are typed, i.e., the sets of their computed values are split into subsets, termed types, that collect together values of a similar kind. In the part of Scheme that we study:

      Computed_values = {Numbers, Booleans, Symbols, P rocedures, T uples}

      Numbers = {1, 2, 5.1,−3, ....}
      Booleans = {#t, #f}
      Symbols = {a, ab1, moshe, ...}

      P rocedures = set of all primitive procedures and closures over values, which is internally split into 1-ary closures from numbers to numbers, 2-ary closures from number pairs to closures, etc.

      T uples = set of all tuples of values, which is internally split into pairs of numbers, pairs of closures, triplets, quadruples of values, etc.

    15. Question 15. What Is A Fixed-point Of A High Order Function?

      Answer :

      Whereas a fixed-point of a first-order function (a function on "simple" values such as integers) is a first-order value, a fixed point of a higher-order function F is another function f-fix such that

      F(F-fix) = F-fix.

      A fixed point operator is a function FIX which produces such a fixed point f-fix for any function F:

      FIX(F) = F-fix.

      Therefore: F( FIX(F) ) = FIX(F).

      Fixed point combinators allow the definition of anonymous recursive functions. Somewhat surprisingly, they can be defined with non-recursive lambda abstractions.

    16. Question 16. What Is Meant By Data?

      Answer :

      The notion of data is usually understood as something consumed by procedures. But in functional languages, procedures are first class citizens, i.e., handled like values of other types. Therefore in such languages the distinction between data and procedures is especially obscure.

    17. Question 17. Determining The Type Of Conditionals?

      Answer :

      The type of a conditional expression depends on the type of the values of the clauses of the conditional. But what if different conditionals evaluate to values that belong to different types. For example, the value of (if x 3 #f) depends on the value of x: might be 3 and might be #f.

    18. Question 18. What Is The Return Type Of Bounded-sqrt,bounded-sqrt-iter?

      Answer :

      The problem is in the conditional that has clauses that return values from different types: Number and Boolean. In order to accommodate such conditionals we allow union types in contract specifications. The resulting contracts:

      Signature: bounded-sqrt(x,bound)

      Purpose: To compute the square root of x, using Newton’s approximations method, if number of iterations does not exceed ’bound’

      Type: [Number*Number -> Number union Boolean]


      (sqrt 16. 7) should produce 4.000000636692939
      (sqrt 16. 4) should produce #f

      Pre-conditions: x >= 0, bound >= 0
      Signature: bounded-sqrt-iter(guess,x,bound)

      Purpose: To compute the square root of x, starting with ’guess’ as initial guess, if number of iterations does not exceed ’bound’

      Type: [Number*Number*Number -> Number union Boolean]


      (sqrt 1 16. 7) should produce 4.000000636692939
      (sqrt 1 16. 4) should produce #f
      Pre-conditions: x >= 0, bound >= 0, guess != 0

    19. Question 19. What Is The Advantage Of Defining The Sum Procedure, And Defining The Three Procedures As Concrete Applications Of Sum?

      Answer :

      1. First, the sum procedure prevents duplications of the computation pattern of summing a sequence elements between given boundaries. Duplication in software is bad for many reasons, that can be summarized by management difficulties, and lack of abstraction – which leads to the second point.
      2. Second, and more important, the sum procedure expresses the mathematical notion of sequence summation. Having this notion, further abstractions can be formulated, on top of it. This is similar to the role of interface in object-oriented languages.

    20. Question 20. What Is The Type (or Types) Of The Values That Result From Its Evaluation(s)?

      Answer :

      Syntax notions: expressions, variables, symbols, forms

      Semantic notions: types, values

      The purpose of type management in programming languages is to prevent unfeasible computations, i.e., computations that cannot be completed due to improper applications of procedures to values. For example, prevent:

      > (+ ((lambda (x) x) (lambda (x) x)) 4)

      +: expects type <number> as 1st argument, given: #<procedure:x>; other

      arguments were: 4

      Language expressions (syntax) are assigned a type (semantics), so that well typing rules can be checked. For example, the above expression is not well typed, since that type of the + primitive procedure is [number*Number –> Number], while the types of the given arguments

      were [T –> T] and Number.

      But, can we guarantee that expressions are well typed? Consider:

      > (define x 4)
      > (+ 3
      (if (> x 0)
      (+ x 1)
      "non-positive value"))
      > (define x 0)
      > (+ 3
      (if (> x 0)
      (+ x 1)
      "non-positive value"))

      +: expects type <number> as 2nd argument, given: "non-positive value";

      other arguments were: 3

      What happened? The expression (if (> x 0) (+ x 1) “non-positive value”) is not well typed. Depending on the runtime value of the variable x, it evaluates either to a number or to a string. Such expressions might cause runetime errors when combined with other operations.

      Programming languages that enforce type checking at static time (before runtime), usually prohibit conditional expressions that might evaluate to different types. In Scheme (Dr. Racket), since types are checked at runetime, such conditionals are allowed, but should be handled with much care.

    21. Question 21. What Is Continuation Passing Style (cps) Programming?

      Answer :

      Continuation Passing Style is a programming method that assumes that every user defined procedure f$ carries a continuation, which is a future computation specification cont, in the form of a procedure, that needs to apply once the computation of f$ ends.

      Since a CPS procedure carries a future computation, they are written as iterative procedures:

      The “bottom” action is directly applied, and all depending actions are postponed to the continuation. A CPS procedure has one of the following formats:

      1. (continuation (primitive-procedure ....))
      2. (CSP-user-procedure .... continuation)
      3. A conditional with the above alternatives

Popular Interview Questions

All Interview Questions

Principles Of Programming Languages Practice Test

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

D Programming Language Tutorial