CS FundamentalsVery hardProduct-company design interview
How many of these statements are correct? 1. Dependency Inversion is a design principle: high- and low-level modules should both depend on abstractions. 2. Dependency Injection is a technique for supplying a component's dependencies from outside, e.g. through its constructor. 3. Inversion of Control is the broader idea that a framework, not your code, calls your code and manages flow. 4. Using a DI container automatically satisfies the Dependency Inversion Principle.
- A. 4
- B. 1
- C. 2
- D. 3
Correct answer: D. 3
1-3 are correct. A container can inject concrete classes just as easily, so high-level code can still depend on low-level details; DIP is about the direction of dependencies, which a tool cannot guarantee.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- Code contains order.getCustomer().getAddress().getCity().toUpperCase(). Which principle does it most directly violate, and why does it…
- A module reads a raw record, cleans it, and passes the cleaned record to a parser whose output is passed to a validator - each step's…
- Match each scenario with its coupling type. P: a module passes a flag telling the callee which of several operations to perform. Q: a…
- A module 'Startup' opens the log file, loads configuration, connects to the database and clears the cache. These tasks are unrelated…
- A UI component subscribes to a long-lived event bus in its constructor but never unsubscribes. Screens using it are opened and closed many…
- In GRASP terms, an Order aggregates its LineItems and has the data needed to initialise them. Which class should create LineItem objects…