What is the term for the ability of a class to provide different…

2025

What is the term for the ability of a class to provide different implementations of a method based on the input parameters?

  1. A.

    Overloading

  2. B.

    Polymorphism

  3. C.

    Inheritance

  4. D.

    Encapsulation

Attempted by 131 students.

Show answer & explanation

Correct answer: A

The term for the ability of a class to provide different implementations of a method based on input parameters is known as method overloading. This occurs when multiple methods in the same class have the same name but different parameter lists (number, type, or order of parameters).
Let's analyze the options:
Option A (Overloading): This directly matches the definition. Multiple methods with the same name but different parameters allow different implementations based on input.
Option B (Polymorphism): While polymorphism includes overloading, it is a broader concept that also includes runtime polymorphism (e.g., method overriding). It is not the most precise term for parameter-based method variation.
Option C (Inheritance): This refers to a class acquiring properties and methods from another class. It does not involve varying method implementations based on parameters.
Option D (Encapsulation): This is about bundling data and methods and controlling access. It does not relate to method implementation variation based on parameters.
Therefore, the correct answer is Option A: Overloading.
हिन्दी उत्तर:
किसी क्लास द्वारा इनपुट पैरामीटर के आधार पर किसी मेथड के अलग-अलग इम्प्लीमेंटेशन प्रदान करने की क्षमता को मेथड ओवरलोडिंग कहा जाता है। इसमें एक ही क्लास में एक ही नाम वाली विभिन्न मेथड्स होती हैं जिनके पैरामीटर अलग-अलग होते हैं।
विकल्पों का विश्लेषण करें:
विकल्प A (ओवरलोडिंग): यह परिभाषा के अनुरूप है। एक ही नाम वाली विभिन्न मेथड्स जिनके पैरामीटर अलग-अलग होते हैं, इनपुट पैरामीटर के आधार पर अलग-अलग इम्प्लीमेंटेशन प्रदान करती हैं।
विकल्प B (पॉलिमॉर्फिज़्म): यह ओवरलोडिंग को शामिल करता है, लेकिन यह एक व्यापक अवधारणा है जिसमें रनटाइम पॉलिमॉर्फिज़्म (उदाहरण के लिए, मेथड ओवरराइडिंग) भी शामिल है। यह पैरामीटर-आधारित मेथड विविधता के लिए सबसे सटीक शब्द नहीं है।
विकल्प C (इनहेरिटेंस): यह एक क्लास द्वारा दूसरी क्लास से गुण और विधियों को प्राप्त करने के बारे में है। यह इनपुट पैरामीटर के आधार पर विधि के विभिन्न इम्प्लीमेंटेशन को शामिल नहीं करता है।
विकल्प D (एन्कैप्सुलेशन): यह डेटा और विधियों को एक एकल इकाई में बंडल करने और पहुंच को नियंत्रित करने के बारे में है। यह इनपुट पैरामीटर के आधार पर विधि इम्प्लीमेंटेशन विविधता से संबंधित नहीं है।
इसलिए, सही उत्तर विकल्प A: ओवरलोडिंग है।

Explore the full course: Bpsc