Question
Which of the following best illustrates the concept of
polymorphism in Object-Oriented Programming (OOP)?Solution
Polymorphism in OOP refers to the ability of a function, method, or object to take on multiple forms. This characteristic allows developers to design interfaces or methods that can perform different tasks based on context. 1. Method Overloading: One of the primary examples of polymorphism is method overloading, where multiple methods share the same name but differ in argument types or counts. 2. Dynamic Behavior: Polymorphism also enables dynamic method invocation at runtime, allowing a subclass to provide a specific implementation for a method defined in its superclass. 3. Extensibility: By allowing objects to process different behaviors through a unified interface, polymorphism enhances code flexibility and scalability. Why Other Options Are Incorrect: β’ B) A class inheriting properties: This describes inheritance, not polymorphism. β’ C) Combining multiple objects: This relates to composition, which involves creating a complex object from simpler ones. β’ D) Restricting access: This refers to encapsulation, which controls data accessibility within a class. β’ E) Relationships between objects: This describes association or aggregation, not polymorphism.
A train crosses a pole and a platform of length 504 metres in 9 seconds and 21 seconds, respectively. Find the length of train.
Train A, moving at 90 km/h, crosses a pole in 8 seconds. Find the time it takes to cross another train of equal length, coming from the opposite directi...
A train covers a distance in 6 hours. If speed is increased by 10 km/h, time reduces by 30 minutes. Find original speed.
Two trains started from stations βAβ and βBβ at same time and started travelling towards each other at speeds of 80 km/hr and 70 km/hr, respecti...
Length of train βMβ is ___ metres, which is ____ metres more than that of train βNβ. Speed of βNβ and βMβ are ____ m/s and ____ m/s res...
- Two trains βT8β and βU8β of lengths 600 metres and 300 metres respectively are travelling towards each other. Ratio of speed of βT8β to βU8οΏ½...
A train of length 420 m can cross a platform of length βyβ m in 30 seconds. Also, it can cross another train of same length as that of the platform,...
Two trains approach each other at 20 kmph and 25 kmph from 2 places 225 km apart. After how many hours they will meet?
A train 150 m long crosses a pole in 12 seconds. It also crosses a platform in 32 seconds. Find the length of the platform.
A goods train leaves a station at a certain time and at a fixed speed. After 8 hours, an express train leaves the same station and moves in the same dir...