300+ TOP Principles of Programming Languages Interview Questions [UPDATED]

  1. 1. What Is Principle Of Programming Language?

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

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

    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. Core Java Interview Questions

  4. 3. What Are The Paradigms Of Programming?

    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
  5. 4. Why There Is Need Of So Many Paradigms?

    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

  6. Core Java Tutorial

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

    Models are:

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

  8. Basic Programming Interview Questions

  9. 6. List Various Type Of Languages?

    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
  10. 7. What Are The Issues For Languages?

    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?

  11. Data Structure & Algorithms Tutorial
    Java-Multithreading Interview Questions

  12. 8. What Is Translation?

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

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

    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

  14. OOPS Interview Questions

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

    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

  16. Computer Programming Tutorial

  17. 11. What Is Parse Tree?

    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.


  18. DB2 SQL Programming Interview Questions

  19. 12. What Is Von-neumann Architecture?

    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).


  20. Core Java Interview Questions

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

    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.

  22. 14. What Is Type Checking/inference?

    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}

    where
    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.

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

    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.


  24. Data Structure & Algorithms Interview Questions

  25. 16. What Is Meant By Data?

    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.

  26. 17. Determining The Type Of Conditionals?

    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.


  27. Computer Programming Interview Questions

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

    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]

    Example:

    (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]

    Example:

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


  29. Basic Programming Interview Questions

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

    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.
  31. 20. What Is The Type (or Types) Of The Values That Result From Its Evaluation(s)?

    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 as 1st argument, given: #; 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”))
    5
    and
    > (define x 0)
    > (+ 3
    (if (> x 0)
    (+ x 1)
    “non-positive value”))

    +: expects type 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.


  32. Advanced C# Interview Questions

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

    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