You are designing a graphics system that involves various shapes like Circle, Rectangle, and Triangle. How might you design the class structure considering reusability and organized hierarchy? 

  • Encapsulation 
  • Polymorphism 
  • Inheritance 
  • Composition
Inheritance would be the most suitable approach in this case. A base class named "Shape" can have common attributes like coordinates and colors. Derived classes like "Circle", "Rectangle", and "Triangle" can then inherit from this base class and add their unique methods and properties related to their specific shapes.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *