C Sharp (C#) - InterfacesYou want to add a new method to an existing interface without breaking existing implementations. How can default interface methods help?ABy removing all existing methods and replacing with new ones.BBy providing a default implementation, existing classes don't need to implement the new method.CBy forcing all classes to implement the new method immediately.DBy making the interface abstract so no implementation is needed.Check Answer
Step-by-Step SolutionSolution:Step 1: Understand interface versioning problemAdding new methods to interfaces usually breaks existing classes that don't implement them.Step 2: Use default interface methods to solve thisProviding a default implementation allows existing classes to continue working without changes.Final Answer:By providing a default implementation, existing classes don't need to implement the new method. -> Option BQuick Check:Default methods enable interface evolution = C [OK]Quick Trick: Default methods prevent breaking changes in interfaces [OK]Common Mistakes:MISTAKESThinking all classes must update immediatelyBelieving interfaces can remove methods safelyConfusing abstract interfaces with default methods
Master "Interfaces" in C Sharp (C#)9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More C Sharp (C#) Quizzes Classes and Objects - Static members vs instance members - Quiz 3easy Classes and Objects - Object instantiation with new - Quiz 1easy Collections - Dictionary key-value collection - Quiz 6medium Collections - LinkedList usage - Quiz 15hard Collections - Dictionary methods and access patterns - Quiz 13medium Exception Handling - When clause in catch - Quiz 9hard Exception Handling - Multiple catch blocks - Quiz 6medium Inheritance - Protected access modifier - Quiz 4medium Polymorphism and Abstract Classes - Why polymorphism matters - Quiz 12easy Polymorphism and Abstract Classes - Runtime polymorphism execution - Quiz 12easy