ZZomato·BehavioralL3DSA Round

Common OOPs Concepts with Pseudocode

viaGlassdoor

Q: Explain common OOPs concepts and write pseudocode demonstrating one (e.g., polymorphism via method overriding). A: Beyond definitions, interviewers want executable-looking pseudocode, e.g.:

class Shape:
  method area() -> abstract

class Circle extends Shape:
  radius
  method area(): return PI * radius * radius

class Rectangle extends Shape:
  width, height
  method area(): return width * height

for shape in [Circle(5), Rectangle(3,4)]:
  print(shape.area())  // runtime polymorphism resolves the correct area()

Be ready to also pseudocode composition-over-inheritance examples and explain why favoring composition (has-a) over deep inheritance hierarchies (is-a) tends to produce more flexible, testable designs.

Add a follow-up question they asked
No follow-ups yet. Be the first to add one.
asked …
LeaderboardSalary
Language
Account