logo

Common Programming Interview Questions

Last Updated: 2023-09-19

Here lists some high level common questions about programming, regardless of which language you use.

What is an Interpreted language?

An Interpreted language executes its statements line by line. Programs run directly from the source code, with no intermediary compilation step.

Examples: Python, Javascript, R, PHP, and Ruby.

What is the difference between statically typed and dynamically typed?

  • Statically typed: the type of the variable is known at the compile time. E.g. C++, Java.
  • Dynamically typed: the type is associated with runtime values, not the named variables. Types are checked during execution. E.g. Python, JavaScript.

What is the difference between strongly typed and weakly typed?

  • Weakly typed: make conversions between unrelated types implicitly. E.g. JavaScript is weakly typed:

    > a = 1
    1
    > a + 'b'
    '1b'
    
  • Strongly typed: don't allow implicit conversions between unrelated types. E.g. Python is strongly typed:

    >>> a = 1
    >>> a + 'b'
    TypeError: unsupported operand type(s) for +: 'int' and 'str'
    

What's the relationship between statically / dynamically and strongly / weakly typed?

As described above, they are correlated. Examples:

  • Static + Strong: Java, C#
  • Static + Weak: C, C++
  • Dynamic + Strong: Python, Ruby
  • Dynamic + Weak: JavaScript, PHP

What is Type assertion in Go? What does it do?

A type assertion takes an interface value and retrieves from it a value of the specified explicit type.

Type conversion is used to convert dissimilar types in GO.

What is variable scope?

The variable scope is defined as the part of the program where the variable can be accessed.

What is variable shadowing?

Shadowing is a principle when a variable overrides a variable in a more specific scope. This means that when a variable is declared in an inner scope having the same data type and name in the outer scope, the variable is said to be shadowed. The outer variable is declared before the shadowed variable.

What are variadic functions?

The function that takes a variable number of arguments is called a variadic function.