Challenger App

No.1 PSC Learning App

★
★
★
★
★
1M+ Downloads
Which of the following statements is correct about polymorphism in programming?

AA function accepts different types/number of arguments and behaves differently.

BA variable accepts different types of values.

CA function returns different types of values.

DA function that does not accept or return any values.

Answer:

A. A function accepts different types/number of arguments and behaves differently.

Read Explanation:

Core Concept

  • Polymorphism is a fundamental principle of Object-Oriented Programming (OOP) that allows objects to be treated as instances of their parent class rather than their actual class.
  • The term derives from Greek, meaning 'many forms'.

Types of Polymorphism

  1. Compile-time Polymorphism (Static Binding):
    • Achieved through Method Overloading and Operator Overloading.
    • The compiler determines which function or operator to invoke at compile time.
  2. Runtime Polymorphism (Dynamic Binding):
    • Achieved through Method Overriding.
    • The specific method to be executed is determined at runtime based on the actual object type, often using virtual functions.

Key Characteristics

  • Flexibility: It allows developers to write code that works on the superclass, which can then be applied to any subclass object without modification.
  • Reusability: Polymorphism promotes code reusability by allowing a single interface to represent different underlying forms (data types).
  • Inheritance Dependency: In most languages, runtime polymorphism is closely tied to Inheritance, as it requires a subclass to override a method defined in its base class.

Related Questions:

Font size is measured in:
Ctrl + X is used to :
Which commands are present in Quick Access Toolbar in MS Word ?

How can we make a selected text bold in MS Word?

  1. Ctrl + B
  2. Home tab -->Font --->Bold
    In MS-Word, a user performs the following sequence of operations. • Selects a paragraph • Presses Ctrl+X in the keyboard • Places the cursor elsewhere in the document • Presses Ctrl+V in the keyboard What will be the result ?