Java - PolymorphismIn Java, which access modifier can be used in the overriding method if the original method is declared as protected?Aprotected or publicBdefault (package-private)CprivateDfinalCheck Answer
Step-by-Step SolutionSolution:Step 1: Recall access modifier rules in overridingThe overriding method cannot reduce visibility. It can keep or increase it.Step 2: Apply to protected methodProtected can be overridden by protected or public, but not private or default (which is less visible).Final Answer:protected or public -> Option AQuick Check:Overriding method visibility ≥ original method visibility = A [OK]Quick Trick: Overriding method can't reduce visibility, can keep or increase it [OK]Common Mistakes:Using private or default which reduce visibilityConfusing final with access modifierAssuming exact same modifier required
Master "Polymorphism" in Java9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Java Quizzes Abstraction - Partial abstraction - Quiz 9hard Classes and Objects - Object lifecycle - Quiz 1easy Classes and Objects - Instance variables - Quiz 4medium Constructors - Constructor overloading - Quiz 2easy Custom Exceptions - Throwing custom exceptions - Quiz 5medium Encapsulation - Why encapsulation is required - Quiz 8hard Exception Handling - Throws keyword - Quiz 7medium Exception Handling - Checked vs unchecked exceptions - Quiz 5medium Object-Oriented Programming Concepts - Procedural vs OOP approach - Quiz 13medium Polymorphism - Upcasting and downcasting - Quiz 4medium