CS FundamentalsModerateCognizant · Capgemini pattern
Match each SOLID principle with the violation it forbids. P. Single Responsibility Q. Interface Segregation R. Open/Closed S. Dependency Inversion 1. A Printer interface forces a basic printer class to implement fax() and scan() 2. An Invoice class both calculates totals and writes itself to a PDF file 3. Adding a new shape means editing a switch statement inside an existing AreaCalculator 4. OrderService constructs a concrete SmtpMailer inside itself
- A. P-2, Q-1, R-3, S-4
- B. P-2, Q-1, R-4, S-3
- C. P-1, Q-2, R-3, S-4
- D. P-3, Q-1, R-2, S-4
Correct answer: A. P-2, Q-1, R-3, S-4
Two reasons to change → SRP (2); a fat interface → ISP (1); editing existing code to add a case → OCP (3); depending on a concrete class instead of an abstraction → DIP (4).
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
- Match each pattern with its intent. P. Builder Q. Facade R. Proxy S. Strategy 1. Give a simple single entry point to a complex subsystem…
- Assertion (A): A lazily initialised Singleton that checks if (instance == null) before creating the object can end up with two instances…
- How many of the following HTTP methods are idempotent by the HTTP specification: GET, PUT, DELETE, POST?
- Assertion (A): In a RESTful API, every request from the client must carry all the information needed to process it, such as an auth token…
- Match each HTTP status code with its meaning. P. 204 Q. 304 R. 409 S. 429 1. Too many requests (rate limit hit) 2. Request conflicts with…
- How many of the following are managed by the cloud provider (not the customer) in a PaaS offering such as a managed app platform? 1. The…