Railways Exam  >  Railways Questions  >   Consider an operation of addition. For two n... Start Learning for Free
Consider an operation of addition. For two numbers the operations will generate a sum. If the operands are string and the same operation would produce a third string by concatenation. This feature is called__________.
  • a)
    Inheritance
  • b)
    Encapsulation
  • c)
    Polymorphism
  • d)
    Binding
Correct answer is option 'C'. Can you explain this answer?
Verified Answer
Consider an operation of addition. For two numbers the operations wil...
Polymorphism is the ability to use an operator or method in different way. It gives different meaning (or functions) to the operators or methods.
Eg. Single operator + behaves differently in different contexts such as integers, string or float referring to the concept of polymorphism.
View all questions of this test
Most Upvoted Answer
Consider an operation of addition. For two numbers the operations wil...
Polymorphism

Polymorphism is a fundamental concept in object-oriented programming that allows objects of different types to be treated as objects of a common type. It enables a single interface to be used for multiple types of objects, providing flexibility and reusability in software design.

Explanation:

Polymorphism allows a single operation to be performed in different ways depending on the types of the operands involved. In the given context, the operation of addition is being performed on two different types of operands: numbers and strings.

When two numbers are added, the operation produces a sum by performing the arithmetic addition. For example, 2 + 3 = 5.

However, when two strings are added, the operation produces a third string by concatenating the two input strings together. For example, "Hello" + "World" = "HelloWorld".

This ability of the addition operation to behave differently based on the types of the operands is an example of polymorphism. It allows the same operation (addition) to be applied to different types (numbers and strings) and produce different results.

Advantages of Polymorphism:

- Reusability: Polymorphism allows objects of different types to be treated uniformly, enabling code reuse and reducing duplication.
- Flexibility: Polymorphism provides flexibility in software design by allowing different implementations of the same operation to be used interchangeably.
- Extensibility: Polymorphism allows new types to be added without modifying existing code, making the system more extensible and scalable.

Other Types of Polymorphism:

- Method Overloading: In method overloading, multiple methods with the same name but different parameters are defined in a class.
- Method Overriding: In method overriding, a subclass provides a different implementation of a method that is already defined in its superclass.
- Interface Polymorphism: Interface polymorphism occurs when a class implements an interface and is treated as an object of that interface type.

In conclusion, the ability of the addition operation to produce different results based on the types of the operands is an example of polymorphism. It allows objects of different types to be treated uniformly and provides flexibility and reusability in software design.
Explore Courses for Railways exam
Consider an operation of addition. For two numbers the operations will generate a sum. If the operands are string and the same operation would produce a third string by concatenation. This feature is called__________.a)Inheritanceb)Encapsulationc)Polymorphismd)BindingCorrect answer is option 'C'. Can you explain this answer?
Question Description
Consider an operation of addition. For two numbers the operations will generate a sum. If the operands are string and the same operation would produce a third string by concatenation. This feature is called__________.a)Inheritanceb)Encapsulationc)Polymorphismd)BindingCorrect answer is option 'C'. Can you explain this answer? for Railways 2024 is part of Railways preparation. The Question and answers have been prepared according to the Railways exam syllabus. Information about Consider an operation of addition. For two numbers the operations will generate a sum. If the operands are string and the same operation would produce a third string by concatenation. This feature is called__________.a)Inheritanceb)Encapsulationc)Polymorphismd)BindingCorrect answer is option 'C'. Can you explain this answer? covers all topics & solutions for Railways 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Consider an operation of addition. For two numbers the operations will generate a sum. If the operands are string and the same operation would produce a third string by concatenation. This feature is called__________.a)Inheritanceb)Encapsulationc)Polymorphismd)BindingCorrect answer is option 'C'. Can you explain this answer?.
Solutions for Consider an operation of addition. For two numbers the operations will generate a sum. If the operands are string and the same operation would produce a third string by concatenation. This feature is called__________.a)Inheritanceb)Encapsulationc)Polymorphismd)BindingCorrect answer is option 'C'. Can you explain this answer? in English & in Hindi are available as part of our courses for Railways. Download more important topics, notes, lectures and mock test series for Railways Exam by signing up for free.
Here you can find the meaning of Consider an operation of addition. For two numbers the operations will generate a sum. If the operands are string and the same operation would produce a third string by concatenation. This feature is called__________.a)Inheritanceb)Encapsulationc)Polymorphismd)BindingCorrect answer is option 'C'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Consider an operation of addition. For two numbers the operations will generate a sum. If the operands are string and the same operation would produce a third string by concatenation. This feature is called__________.a)Inheritanceb)Encapsulationc)Polymorphismd)BindingCorrect answer is option 'C'. Can you explain this answer?, a detailed solution for Consider an operation of addition. For two numbers the operations will generate a sum. If the operands are string and the same operation would produce a third string by concatenation. This feature is called__________.a)Inheritanceb)Encapsulationc)Polymorphismd)BindingCorrect answer is option 'C'. Can you explain this answer? has been provided alongside types of Consider an operation of addition. For two numbers the operations will generate a sum. If the operands are string and the same operation would produce a third string by concatenation. This feature is called__________.a)Inheritanceb)Encapsulationc)Polymorphismd)BindingCorrect answer is option 'C'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Consider an operation of addition. For two numbers the operations will generate a sum. If the operands are string and the same operation would produce a third string by concatenation. This feature is called__________.a)Inheritanceb)Encapsulationc)Polymorphismd)BindingCorrect answer is option 'C'. Can you explain this answer? tests, examples and also practice Railways tests.
Explore Courses for Railways exam

Top Courses for Railways

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev