Question
Which of the following best represents the concept of
polymorphism in Object-Oriented Programming?ÂSolution
Polymorphism in Object-Oriented Programming (OOP) allows methods to be defined in different forms across different derived classes, typically by overriding or overloading methods. This enables a single method to exhibit multiple behaviors, depending on the object that invokes it. For example, a base class method draw() in a shape class could be defined differently in derived classes like Circle and Rectangle, where each class implements its unique version of draw(). This approach promotes flexibility, reduces code duplication, and allows developers to manage code easily as new classes are added, embodying one of OOP’s core principles. Polymorphism is critical for creating extensible and maintainable code, as it enables a system to process objects of various types through a common interface. Option A (Encapsulation) - Encapsulation is the OOP principle of hiding internal details and exposing only necessary features through a class interface, which differs from polymorphism’s focus on varied behaviors. Option C (Aggregation) - Aggregation describes a "has-a" relationship between classes, where one class contains references to another, unrelated to polymorphic behavior. Option D (Encapsulation) - This concept of grouping related fields and methods within a class refers to encapsulation, not polymorphism. Option E (Unrelated Classes) - Allowing objects of unrelated classes to connect without a common functionality does not represent polymorphism, which requires shared interfaces or inheritance.
UPSET : SETUP :: TITPOT : ?
Choose the pair which is related in the same way as the words in the first pair from the given choices.
INDIA : TIGER :: USA : ________________
Select the correct mirror image of the given figure when the mirror is placed at line MN as shown.
In the following question, four letter pairs are given. The letters on left side of (–) is related to the letters on the right side of (–) with som...
Which two numbers should be interchanged to make the given equation correct?Â
8 × 9 ÷ 4 + 5 – 3 = 2Â
Select T the option figure that will replace the question mark (?) in the figure given below to complete the pattern.
Select the set in which the numbers are related in the same way as are the numbers of the given set. (NOTE: Operations should be performed on the whole ...
Select the combination of letters that when sequentially placed in the blanks of the given series will complete the series.
_ BCD _ _ ABC _ _ E _...
In a year-end examination, 6 papers-Maths, Physics, Geography, Economics, Chemistry, History - are scheduled on 6 consecutive days of a week (Monday - S...
Select the option that will fill in the blank and complete the given series.
ABCD, ________, ΧΥΖΑ, XXXX, UVWX, UUUU