"Explain dependency injection. How does it differ from creating dependencies inside a class, and why does it improve maintainability and testing?"