1Z0-811 Object-Oriented Programming Practice Question
In a Java application, a class 'OrderProcessor' contains a method that processes orders. The method currently handles multiple responsibilities: validating order data, calculating totals, updating inventory, and sending notifications. The team wants to refactor this method to follow the Single Responsibility Principle. Which action should they take?
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Create separate classes or methods for each responsibility and compose them in OrderProcessor
It separates each responsibility into its own class or method and composes them in OrderProcessor, which adheres to the Single Responsibility Principle. Option A is wrong because a single utility method with if-else still violates SRP by handling multiple responsibilities. Option B is wrong because overriding in subclasses does not separate concerns within the same method; it shifts responsibilities but does not eliminate the violation. Option C is wrong because merging responsibilities into a superclass increases coupling and does not adhere to SRP.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Use a single utility method that uses if-else for each case
Why it's wrong here
The method still handles multiple responsibilities.
- ✗
Override the method in subclasses for each responsibility
Why it's wrong here
Each subclass would still need to handle all responsibilities.
- ✗
Merge all responsibilities into a superclass
Why it's wrong here
This still combines all concerns in one class.
- ✓
Create separate classes or methods for each responsibility and compose them in OrderProcessor
Why this is correct
Each class/method has one reason to change, following SRP.
Go deeper
Related to this question
About these practice questions
This 1Z0-811 question is part of Courseiva's 481-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This 1Z0-811 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-811 exam.