Which of the following best represents the concept of polymorphism in Object-Oriented Programming?
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.
Which of the following statement(s) is/are false?
I. Only one person sits between P and the one who likes Blueberry when counted left of P.
<...Who reads Dainik Bhaskar?
Six people L, M, N, J, P and R are sitting around a circular table, facing towards the centre. M is sitting second to the right of J. One person is sitt...
Who among the following person sits opposite to the one who is third to the left of B?
Six persons are sitting in two straight rows, facing north. Their names are A, B, C, D, E and F. A and F are sitting at diagonally opposite ends. B is i...
Six persons S, T, U, V, W and X are sitting in a row facing north. X is not sitting beside U and U is sitting at the extreme right. Only S is sitting be...
Who sits in front of F?
Who among the following likes black color?
Amit, Gaurav, Hatim, Varun, Yukti and Zaid are sitting in a straight line, all facing the north. Gaurav is fourth to the left of Amit. Yukti is sitting ...
If the position of G and F are interchanged, then the position of C and G are interchanged, then who among the following person sits second to the righ...