Need to practice your Software Engineering skills for an upcoming job interview? Try solving these Software Engineering interview questions that test knowledge of OOP, data structures, design patterns, and other skills. We’ll provide feedback on your answers, and you can use a hint if you get stuck.
These Software Engineering interview questions are examples of real tasks used by employers to screen job candidates such as software engineers, web developers, mobile developers, and others that need to understand how software systems work together, how to optimize them, and how to design systems to avoid potential issues.
1. HTTP Request
A user types www.testdome.com into their browser's address bar for the first time, presses enter, the webpage loads, and renders successfully.
Select the statements that are correct.
(Select all acceptable answers.)
2. Web App Architecture
During a discussion about architecture for a new web app the following sketchup was made:
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.
3. Big O Notation
For the following pseudocode functions, choose the big O notation that accurately describes its worst-case complexity.
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
4. Serialize Cart
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 wants to have the possibility of allowing loosely coupled plugins to be able 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.
(Select all acceptable answers.)
class JsonSerializer
Should be changed to:
class JsonSerializer inherits ISerializer
interface ISerializer
public function serialize(Dictionary<int, string>) : string
end interface
enumeration SerializerType
Json,
Xml
end enumeration
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())
else
throw Error("Not implemented error!");
end if
end function
public function serialize(serializer : ISerializer) : string
return serializer.serialize(content.clone())
end function
private content : Dictionary<int, string>
to:
public content : Dictionary<int, string>
so that plugins can directly manipulate and save the shopping cart.5. Stack vs Queue
Answer the questions below regarding correct usage of data structures.
Given an empty object stackOfNumbers of type Stack, review the sequence of function calls:
stackOfNumbers->Push(10)
stackOfNumbers->Push(12)
stackOfNumbers->Push(13)
stackOfNumbers->Peek()
stackOfNumbers->Push(8)
stackOfNumbers->Pop()
stackOfNumbers->Push(9)
stackOfNumbers->Peek()
If Pop() were called again, it would return:
Given an empty object queueOfNumbers of type Queue, review the sequence of function calls:
queueOfNumbers->Enqueue(10)
queueOfNumbers->Enqueue(12)
queueOfNumbers->Enqueue(13)
queueOfNumbers->Peek()
queueOfNumbers->Enqueue(8)
queueOfNumbers->Dequeue()
queueOfNumbers->Enqueue(9)
queueOfNumbers->Peek()
If Dequeue() were called again, it would return:
In which one of these scenarios might you use a Queue instead of a Stack?
6. RESTful Web Services
Select the statements about RESTful web services that are correct.
(Select all acceptable answers.)
7. Font Formatting
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.