Top 5 Object Oriented Analysis and Design Interview Questions for Programmers, Software Engineers

Testing the design skill of a candidate is quite common in programming job interviews. Questions like, how do you design a vending machine or a traffic control system is very popular in object-oriented programming language interviews, like Java and C++. Designing a software System requires good experience and knowledge of tools of object-oriented design and analysis. You should not only be good at OOP fundamentals like Abstraction, Inheritance, Polymorphism, Encapsulation, Coupling, Cohesion, Association, Aggregation, or Composition but also on several crucial object-oriented design principles like SOLID Principles of Object-Oriented Design, which is building block for writing flexible and maintainable code.

Good knowledge of when to use a class over an interface is also essential for designing a maintainable software or Java application. Now, questions are how do you develop such skills? You need to practice and practice hard. This is why I am sharing some frequently asked object-oriented design questions from Java programming interviews here.

Anyway, Software design has many facets, object-oriented system design is just one of them. Sometimes, you may be asked to design a database for an e-commerce application. Database design is totally different than object-oriented design.

There you need to follow rules of flexible and maintainable designs, like. Normalization. You need to make sure your tables are in 3rd normal form, and there is a nice balance between duplication of data and easiness of querying the data.

Btw, this tutorial is about object-oriented system design, and I'll share questions on that. I'll write about SQL and database design sometime later to give you more information and some practice questions as well.

Another thing to note is that now there are a couple of excellent courses available online which can help you with this challenging aspect of coding interviews. I have tried the Grokking The System Design Interview and Grokking the Object-Oriented Design Interview courses from Educative and I must say they are excellent to prepare well.

These courses are designed by the hiring managers of Google, Facebook, Microsoft, and Amazon. They not only has a set of carefully handpicked case studies, which have been repeatedly asked at the top tech companies but also provides a thorough experience to handle different object-oriented design scenarios.





5 Object-Oriented and Software Design Interview Questions

Here is my list of frequently asked object-oriented and software design questions from programming job interviews. You will find such kind of questions not only on biggies like Amazon, Google, Microsoft, and Facebook but also on small startups and service-based companies like Infosys, Wipro, TCS, and Cognizant.

Though for a comprehensive preparation, I also suggest you take a look at Java Programming Interview Exposed, which contains questions from all important Java topics, like Core Java, data structure and algorithms, multithreading, garbage collection, JVM internals, and frameworks like Spring and Hibernate.


Problem 1: Design a Vending Machine in Java (solution)
You need to design a Vending Machine which follows the following requirements
Accepts coins of 1,5,10,25, 50 Cents, i.e. penny, nickel, dime, and quarter as well as 1 and 2 dollar note
Allow user to select products e.g. CANDY(10), SNACK(50), NUTS(90), Coke(25), Pepsi(35), Soda(45)
Allow users to take a refund by canceling the request.
Return the selected product and remaining change if any
Allow reset operation for vending machine supplier


Problem 2: Design a URL shortener service like goo.gl (solution)
You need to design a URL shortener service like bit.ly or goo.gl. You can insert the full URL and get a short one. Your short URL should also record the stats about how many times it was accessed. Your system should also be able to handle concurrent users and millions of URL shortening per day. Think about auditing and bookkeeping, as well.

Btw, If you struggle to start with these questions, then you can also see the Grokking The System Design Interview, which contains a whole chapter on designing URL shortening services like TinyURL, Google URL, and Bitly. 

Here is the system diagram from the same course which explains the different components of a URL shortening service. I strongly suggest you check the course, this lesson is also available for FRE preview

Top 5 Object Oriented Design Interview Questions for Programmers, Software Engineers



Problem 3: Design a Lift system in your programming language. (solution)
An elevator is a combination of at least two elevators, one going up and another coming down. The goal is to minimize the waiting time of the user. Make sure you how your design will evolve if a lift is installed on high rise buildings over 20 floors.

How many lifts you need to server 40 floors with waiting time no less than 30 seconds on average. Think about the parking strategy of your lift, i.e. which floor they should be resting or should they keep going up or down, etc.


Problem 4: Desing and implement LRU cache in Java or C++?
An LRU cache stands for Least Recently Used. It should remove the least recently used item from the cache to make space for a new item. Think about the persistence strategy of the cache. how do you build-cache after crash etc


Problem 5: Design a Traffic Controller System for a Junction?
You need to design software to control traffic lights at a junction where traffic is coming from four sides. It should follow basic traffic rules, allow a pedestrian to cross the road, and traffic to pass in a reasonable time. How do you optimize the waiting time with respect to high traffic from one direction, like during morning and evening rush hours?

If you need some help than a similar question about designing Airline Management System can be found on Grokking the Object-Oriented Design Interview course, you can go through that lesson to learn more about how to deal with such a question.

Top 5 Object Oriented Design Interview Questions for Programmers, Software Engineers



That's all in this list of frequently asked software design questions from programming job interviews. As I said, object-oriented analysis and design are some of the most sought after skills in job interviews. If you can demonstrate excellent design and coding skills, along with writing a good JUnit test, it would create an excellent impression on the interviewer.

Everybody like good professional developers and unit testing is one of that thing which separate a professional to non-professional software engineers. If you have been asked any other object-oriented design question or anything related to software design, feel free to share it with us.

Other Programming Interview Questions for Java Programmers
  • 10 tricky Java Interview Questions for Experienced developers (list)
  • 21 frequently asked SQL Queries from Programming Interviews (list)
  • 18 Java design pattern interviews questions with answers (list)
  • 12 multi-threading and concurrency Interview Questions (list)
  • 40 Core Java Interview Questions from Phone Interviews  (list)
  • 21 Array Concept Interview Questions in Java? (list)
  • 22 Java Inheritance Interview Questions with Answers (list)
  • 30 OOP Concept Interview Questions with Answers (list)
  • Top 20 System Design Interview Questions for Programmers (questions)
  • 10 tips and 101 Coding Problems to Crack Your Next Interview (article)
  • 50+ Data Structure and Algorithms Problems from Interviews (article)
  • 10 Courses to Crack your Programming Interviews (courses)

Thanks for reading this article so far. If you like these Object-Oriented Design Questions, then please share it with your friends and colleagues. If you have any questions or doubt then, please drop a note,

P. S. - If you need more questions, I suggest you check out the Grokking the Object-Oriented Design Interview course on Educative, an interactive learning platform. This course is a complete guide to master the OODI. It is designed by the hiring managers of Google, Facebook, Microsoft, and Amazon and contains solutions to some of the frequently asked object-oriented design questions from these tech giants.

5 comments:

  1. Great post.. can you post solutions as well ?

    ReplyDelete
  2. I am unable to understand problem 4, can you give a brief solution of it?
    Thanks in advance.
    Kemar J.

    ReplyDelete
  3. Replies
    1. Sorry, what do you mean? Are you not able to solve these problems or description not clear to you? The description has kept loose so that you don't have too many constraint to create solution.

      Delete