Try to solve 5 Software Engineering interview questions below. Hints can help you find answers to questions you are having trouble with.

1. Web App Architecture

Software architecture Solution architecture

During a discussion about architecture for a new web app the following sketchup was made:

Web app architecture

The authors of the sketchup forgot to write the descriptions for three components marked with red numbers.

Select the best choice, regarding the context, for the description that should define each component.

Component 1.

Component 2.

Component 3.


2. Big O Notation


For the following pseudocode functions, choose the big O notation that accurately describes its worst-case complexity.

function Doubler(number : integer)
  integer i = 1
  loop (while i < number)
    i = i * 2
  end loop
end function

function GetFirstElement(elements : array) : integer
  return elements[0]
end function

function DisplayPairsFromList(elements : array)
  integer i = 0
  integer size = elements->Count()
  loop (while i < size)
    integer j = 0
    loop (while j < size)
      Display(elements[i] + ", " + elements[j])
      j = j + 1
    end loop
    i = i + 1
  end loop
end function

function Recursive(number : integer) : integer
  if (number <= 1)
    return number

  return Recursive(number - 4) + Recursive(number - 2)
end function

3. Serialize Cart

Inheritance OOP

In a language that supports OOP paradigm, we have the following code that serializes the content of a shopping cart to JSON format:

class ShoppingCart
  private content : Dictionary<int, string> 

  public function serialize() : string
    return new JsonSerializer().serialize(content.clone())
  end function
end class

class JsonSerializer  
  public function serialize(value : Dictionary<int, string>) : string
    ' Code that serializes dictionary to JSON format and returns it as string
  end function
end class

A client now wants to have the possibility for allowing plugins to serialize the shopping cart content to their own formats (e.g., XML). Select lines of code that, together, would extend the code above to allow this extensibility.

(Select all acceptable answers.)

class JsonSerializer
Should be changed to:
class JsonSerializer inherits ISerializer
Add interface definition:
interface ISerializer
  public function serialize(Dictionary<int, string>) : string
end interface
Add Enum definition that will be extended as new plugins will be added (e.g., to add XML serialization):
enumeration SerializerType
end enumeration
Change ShoppingCart's serialize implementation to one like below (e.g., to add XML serialization):
public function serialize(serializer : SerializerType) : string
  if(serializer == SerializerType.Json)
    return new JsonSerializer().serialize(content.clone())
  else if(serializer == SerializerType.Xml)
    return new XmlSerializer().serialize(content.clone())
    throw Error("Not implemented error!");
  end if    
end function
Change ShoppingCart's serialize implementation to:
public function serialize(serializer : ISerializer) : string
  return serializer.serialize(content.clone())
end function
Change ShoppingCart's data member from:
private content : Dictionary<int, string>
public content : Dictionary<int, string>
so that plugins can directly manipulate and save the shopping cart.

4. Stack vs Queue

Data structures Queue Stack

Answer the questions below regarding correct usage of data structures.

Given an empty object stackOfNumbers of type Stack, review the sequence of function calls:


If Pop() were called again, it would return:

Given an empty object queueOfNumbers of type Queue, review the sequence of function calls:


If Dequeue() were called again, it would return: 

In which one of these scenarios might you use a Queue instead of a Stack?


5. Font Formatting

Design patterns OOP Structural patterns

A word processor uses the following code for defining font format:

class FontFormat inherits Object
  private fontName : string
  private fontSize : int

  public constructor(name : string, size : int)
    fontName = name
    fontSize = size
  end constructor

  public function getFontName : string
    return fontName
  end function

  public function getFontSize : int
    return fontSize
  end function

  override public function equals(obj : object) : bool
    if(!(obj instanceof FontFormat))
      return false
    end if
    FontFormat f = (FontFormat)obj
    return f.getFontName() == fontName && f.getFontSize() == fontSize
  end function

  override public function getHashCode() : int
    return fontName.getHashCode() ^ fontSize.getHashCode()
  end function
end class

Analysis shows that even the largest documents use fewer than a hundred different combinations of font name and size. The same analysis shows that the application sometimes uses thousands of FontFormat objects, most of which share the same font name and size.

(Fill in the blank with the software design pattern that solves the issue.)

The software design pattern can be used to minimize the memory footprint by sharing FontFormat objects.


If you feel ready, take one of our timed public Software Engineering Interview Questions tests:
Software Engineering

Software Engineering Online Test (Easy / Hard)

Not exactly what you are looking for? Go to our For Jobseekers section.