Polymorphism occurs when the methods of the child class.

  1. Override the parent class methods but maintain the implementation

  2. Maintain the same return type and arguments as the parent class, but implement it differently

  3. Have different return types and arguments than the parent class

  4. Are Virtual


Correct Option: B

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) Override the parent class methods but maintain the implementation - This option is incorrect. Polymorphism does involve overriding methods from the parent class, but it allows for changing the implementation of these methods, not maintaining the same implementation.

Option B) Maintain the same return type and arguments as the parent class but implement it differently - This option is correct. Polymorphism occurs when a child class provides a different implementation of a method that is already defined in the parent class. The method in the child class must have the same return type and arguments as the method in the parent class.

Option C) Have different return types and arguments than the parent class - This option is incorrect. Polymorphism requires the child class method to have the same return type and arguments as the parent class method. Having different return types and arguments would result in method overloading, not polymorphism.

Option D) Are Virtual - This option is incorrect. Virtual methods in object-oriented programming languages allow for method overriding, but they are not a requirement for polymorphism. Polymorphism can occur with or without virtual methods.

The correct answer is B. This option is correct because it accurately describes polymorphism, where the child class methods maintain the same return type and arguments as the parent class methods but implement them differently.

Find more quizzes: