Question 21
EasyWhat is separation of concerns?
- A.
Dividing a program into parts that each deal with one separate concern
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Object-Oriented Programming
What is separation of concerns?
Dividing a program into parts that each deal with one separate concern
Writing comments separately
Keeping all code in one file
Running programs on separate computers
Sign up free to see the answer and a step-by-step explanation.
What is a 'God class'?
A class only administrators may use
The base class of all classes
A very fast class
A class that knows or does far too much, an anti-pattern
Sign up free to see the answer and a step-by-step explanation.
What is refactoring?
Rewriting a program in another language
Fixing typing mistakes in comments
Adding new features
Improving the structure of code without changing what it does
Sign up free to see the answer and a step-by-step explanation.
What is a code smell?
Code with no comments
A sign in the code that suggests a deeper design problem
A compiler warning
A bug that crashes the program
Sign up free to see the answer and a step-by-step explanation.
The 'Gang of Four' book groups design patterns into which three categories?
Creational, structural and behavioural
Simple, medium and hard
Input, output and storage
Static, dynamic and abstract
Sign up free to see the answer and a step-by-step explanation.
To which category of design patterns does Observer belong?
Structural
Architectural
Creational
Behavioural
Sign up free to see the answer and a step-by-step explanation.
A Report class must be edited whenever the report's layout changes and whenever the tax rules change. Which principle does it violate?
Single Responsibility Principle
Don't Repeat Yourself
Liskov Substitution Principle
Interface Segregation Principle
Sign up free to see the answer and a step-by-step explanation.
A class Invoice calculates totals, saves itself to a database and prints itself as a PDF. Which principle does it violate?
Interface Segregation
Single Responsibility
Liskov Substitution
Open/Closed only
Sign up free to see the answer and a step-by-step explanation.
Adding a new payment type requires editing a big if-else chain in PaymentProcessor. Which principle is being violated?
DRY
Single Responsibility only
Dependency Inversion only
Open/Closed
Sign up free to see the answer and a step-by-step explanation.
Square extends Rectangle, but setting a Square's width also changes its height, surprising code written for rectangles. Which principle does this break?
Open/Closed
Single Responsibility
Liskov Substitution
Interface Segregation
Sign up free to see the answer and a step-by-step explanation.