Start learning 50% faster. Sign in now
The Open/Closed Principle (OCP) is one of the SOLID principles for object-oriented design. 1. Key Idea: Software entities like classes, modules, and functions should be extendable without altering existing code. 2. Implementation: Achieved through techniques like inheritance, polymorphism, or interfaces that allow new functionality to be added without modifying the original codebase. 3. Benefits: Promotes code reusability, reduces the risk of introducing bugs into stable code, and facilitates easier maintenance and scaling. 4. Example: A class for processing payments could use an interface for payment methods. Adding a new payment type would require extending the interface, not modifying the class. This principle ensures that software systems are adaptable to new requirements without jeopardizing existing functionality. Why Other Options Are Incorrect: • A) SRP: Focuses on assigning one responsibility to each class/module but does not address extensibility. • C) LSP: Ensures derived classes can replace base classes without altering behavior, unrelated to modification. • D) ISP: Advocates for creating specific interfaces for clients, reducing unnecessary dependencies. • E) DIP: Encourages high-level modules to depend on abstractions rather than concrete implementations.
A trader bought an article for Rs. 1200 and marked it 25% above of its cost price. If he sold it after giving a discount of Rs. 60 then find the profit ...
Seema’s present age is 1(1/2) times of her marriage. She married 12 years ago. Now she has a daughter whose age is 2 more than one third of her ag...
Three years from now, Aman's age will be 80% greater than what it was five years ago. The average of Aman's current age and Bishn...
The ratio of the present ages of father and his son is 9:4. The product of their ages 3 years ago was 24 times of his son’s age that year. What was so...
Today is Reena’s birthday. She has turned 34. Reena is twice as old as Deepa was when Reena was as old as Deepa is now. How old is Deepa now?
A is 3 years older than B while C is 4 years younger than B. The ratio of age of A, 6 years hence and age of B, 4 years ago is 3:2. What was age of C, 1...
The current age ratio of Rahul to Sakshi is 3:2. Additionally, the ratio of Rahul’s age five years ago to Sakshi’s age ten ye...
8 years ago from now, ratio of ages of ‘R’ and ‘L’ was 3:5, respectively. If ‘L’ is 7 years elder to ‘R’, then what will be the age of �...
Sum of the present ages of A, B, C and D is 40 years. After 6 years ratio of their ages is 6:5:3:2. What is C’s present age?
Sushil’s present age is 1/2 times of her father’s age. After 13 years, father’s age will be 3 times the age of Sonu. If 3 years ago So...