For an Amazon SDE interview, object-oriented programming questions usually test whether you understand core design principles, not just syntax. Interviewers expect you to explain concepts clearly and apply them in class design or system modeling problems.
Below are the essential OOP concepts that typically appear.
A class is a blueprint for creating objects. It defines attributes (data) and methods (behavior).
An object is an instance of a class.
class Car:
def __init__(self, brand, speed):
self.brand = brand
self.speed = speed
def drive(self):
return f"{self.brand} is driving at {self.speed} mph"
car1 = Car("Toyota", 60)
print(car1.drive())
Interview focus
__init__)Encapsulation means bundling data and methods together and restricting direct access to internal state.
Purpose: