Top 10 Object Oriented Analysis and Design Interview Questions and Problems for Experienced Developers

Check your Object Oriented Analysis and Design skills by solving these Object Oriented Design Problem before your next Programming job interview

javinpaul
Javarevisited
10 min readJul 29, 2022

--

Top 10 Object Oriented Analysis and Design Interview Questions and Problems for Experienced Developers

Testing Object Oriented analysis and 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 are 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 the 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, the 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 and Normalization. You need to make sure your tables are in 3rd normal form, and there is a nice balance between duplication of data and the 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 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 provide a thorough experience to handle different object-oriented design scenarios.

10 Object-Oriented and Software Design Interview Questions and Problems

Here is my list of frequently asked object-oriented and software design questions from programming job interviews. You will find such kinds 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:
1. It should accepts coins of 1,5,10,25, 50 Cents, i.e., penny, nickel, dime, and quarter as well as 1 and 2 dollar note

2. Allow user to select products like CANDY(10), SNACK(50), NUTS(90), Coke(25), Pepsi(35), Soda(45)

3. Allow users to take a refund by canceling the request.

4. Return the selected product and remaining change if any

5. Allow reset operation for vending machine supplier

You can try solving the problem on your own before looking at the solution. At least come up with classes and method names and relationship between classes. Preparing a UML diagram is bonus.

How to design a Vending Machine in Java

Problem 2: Design a URL shortener service like bit.ly? (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 a FREE preview.

How to design a URL Shrotner service like bit.ly

Problem 3: Design a Lift system in your programming language?

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 do you need to serve 40 floors with a waiting time of no less than 30 seconds on average. Think about the parking strategy of your lift, i.e., which floor they should be resting on or should they keep going up or down, etc.

If you need solution, you can watch the following video which explains how to design a lift system step by step but as I said, you must try to come up with basic design first.

Problem 4: Design 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? Let me give you a hint, you can use a LinkedHashMap to build an LRU cache in Java.

If you need full solution, you can also checkout this YouTube video by Backtobackswe, one of the best place to prepare for coding interviews

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

How to design a Traffic controller system

Problem 6: How do you Design Parking Garage?

This is another popular object oriented design and system design question which is often asked on FAANG companies. Many people said that this was asked to them during Amazon interview. Most of the time interviewer will just give you vague requirement like this and you need to ask questions to clarify like how it should behave like how many parking slots, how a slot is taken, reserved or released etc.

If you need help to solve this problem, you can always checkout this video from Exponent’s YouTube channel. If you don’t know Exponent is specialized in FAANG interview prep and they have an excellent System design course which has helped many people to clear System design interviews on FAANG companies.

Problem 7: Design a Trade Position Aggregator or Portfolio Manager?

You need to design a system where trades are fed at real time and you need to calculate live position by aggregating buy and sale trades for each symbol. You also need to allocate trades on accounts which is part of trade.

Here are rules and constraints you need to follow while designing this system:

1. When Direction is Buy and operation is NEW or AMEND, you need to increase the position as your exposure increases.

2. When Direction is Sell and operation is CANCEL, you need to increase the position as your exposure is not reducing.

3. When Direction is Buy and operation is Cancel reduce position;

4. When Direction is Sell, and operation is NEW or AMEND, reduce positions.

If you need a solution, you can see this tutorial where I have solved this question in Java, step by step.

Problem 8: How do you design a Distributed Message Queue?

This is another interesting Object oriented design question which is commonly asked during System design interviews. In this problem you need to design a distributed message queue.

Here are high level requirement:

  1. Producers send messages
  2. Consumers consume messages
  3. Messages can be consumed repeatedly or only once

How will you approach this problem? To give you an hint, here is a nice diagram from ByteByteGo and Alex Xu, author of one of the most popular System design interview book called System Design Interview — An insider’s guide

Top 10 Object Oriented Analysis and Design Interview Questions and Problems for Experienced Developers

Problem 9: How do you Design a Library Management System in Java or your favorite programming language?

This is another interesting problem to test your object oriented design skill, in this problem you need to design a library management system which should allow you to

  1. Add new book,
  2. Rent or issue a book to readers,
  3. Send reminders when due date is near
  4. and also print a report of overdue books.
  5. It should also provide search functionality so that readers can find books easily.

This is a massive OOP Design problem and not easy to solve but not difficult as well. But if you need guidance, you can checkout the solution which is part of Educative’s Grokking the Object-Oriented Design Interview course but its freely available.

Problem 10 — How do you design a Blackjack game?

If you have played card games then you will be familiar with popular Card game now you need to use your object oriented programming skill to design and create a Blackjack game in Java or your favorite programming language.

The Grokking the Object-Oriented Design Interview course has a solution of that but its not free but don’t worry, here is a nice YouTube tutorial which will teach you how to create Blackjack in Java.

Other Popular Object Oriented Design Questions you can practice:

  1. How to design an ATM machine?
  2. How to design a Tic-Tac-Toe in Java?
  3. How to design Tetris Game in Java?
  4. How to design a car rental system
  5. How to design a Movie Ticket system
  6. Design a Chess game in Java
  7. Design a Hotel Management System in Java?
  8. How to design YouTube?
  9. How to design a Chat system like WhatsApp or Facebook Messenger
  10. Whatsapp System Design
Hwo to design Youtube in Java

That’s all in this list of frequently asked Object Oriented 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.

Best System Design and Object Oriented Interview Resources

If you need more resources like books, and online courses to prepare for the System design Interview here are my recommendations:

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.

--

--

javinpaul
Javarevisited

I am Java programmer, blogger, working on Java, J2EE, UNIX, FIX Protocol. I share Java tips on http://javarevisited.blogspot.com and http://java67.com