Skip to content
Preptima

Top 4 Interfaces Interview Questions

Browse 4 real-world technical and behavioral interview questions about Interfaces. Review scenarios, edge cases, and architectural best practices.

When would you reach for an abstract base class rather than a Protocol, and what does isinstance check in each case?

Use a Python ABC when you need nominal inheritance and runtime instantiation checks; use a Protocol when a type checker should accept any object with the required methods, even without inheritance. Use this abstract base classes answer to show the decision, trade-off, and evidence rather than a memorised definition. It also connects protocols to the point an interviewer is testing.

hardconcept

Design a parking lot system — you have 90 minutes, working code at the end.

In a parking lot machine coding round, scope one deterministic flow of park, unpark and charge, model Vehicle, Slot, Level, Ticket and a ParkingLot facade, then push slot allocation and pricing behind strategy interfaces so review-time variants are configuration rather than surgery.

harddesign

Your function returns nil on the success path, the caller checks err != nil, and the check fires anyway. What happened?

A Go interface is non-nil when it holds a concrete type, even if the concrete pointer value is nil. Returning a typed nil pointer as an error creates an interface value that fails err == nil checks.

hardconcept

Go gives you no project layout and no dependency-injection container. How do you structure a service so it stays testable as it grows?

Wire dependencies explicitly through constructors from one place in main, define narrow interfaces where they are consumed rather than implemented, and keep handlers thin enough that the logic beneath is testable without a server. With no framework, these are decisions rather than defaults.

mediumdesign