What is coercion in Polymorphism

+1 vote
Is it like implicit type conversion?
Jan 31, 2019 in Java by Neha
• 6,300 points

recategorized Jan 31, 2019 by Neha 1,148 views

2 answers to this question.

0 votes

Polymorphic coercion deals with implicit type conversion done by the compiler to prevent type errors. A typical example is seen in an integer and string concatenation.

String str="string"=2;

answered Jan 31, 2019 by Frankie
• 9,810 points
0 votes
Implicit type conversion is called coercion polymorphism. Assume that we have a function with argument int. If we call that function by passing a float value and if the the run-time is able to convert the type and use it accordingly then it is coercion polymorphism.

Now with this definition, let us see if Java has coercion polymorphism. The answer is half yes. Java supports widening type conversion and not narrowing conversions.

answered Jun 25, 2019 by anonymous

Related Questions In Java

+1 vote
3 answers

What is the syntax to declare and initialize an array in java?

You can use this method: String[] strs = ...READ MORE

answered Jul 25, 2018 in Java by samarth295
• 2,220 points
0 votes
2 answers

What is the use of toString method in Java and how can I use it ?

Whenever you require to explore the constructor ...READ MORE

answered Aug 23, 2018 in Java by Daisy
• 8,110 points
0 votes
2 answers

What is the difference between Set and List in java?

LIST SET Duplicates YES NO Order Ordered Depends on Implementation Positional Access YES NO List is an ordered sequence ...READ MORE

answered Aug 14, 2019 in Java by Sirajul
• 59,090 points
0 votes
2 answers

What is the use of @Override annotation in Java ? When do we use it ?

@Override annotation is used when we override ...READ MORE

answered Aug 14, 2019 in Java by Sirajul
• 59,090 points
+2 votes
3 answers

what is the practical use of polymorphism in Python?

Polymorphism is the ability to present the ...READ MORE

answered Mar 31, 2018 in Python by anto.trigg4
• 3,440 points
0 votes
3 answers

Does Java support Default Parameters?

You can try this with method overloading. void ...READ MORE

answered Sep 21, 2018 in Java by Sushmita
• 6,900 points
+12 votes
13 answers

Default parameters of XMS and XMX in JVM

Run this code to see all the ...READ MORE

answered Nov 13, 2018 in Java by anonymous
0 votes
1 answer

What is the difference between Polymorphism, Overriding and Overloading?

As far as I know, the main ...READ MORE

answered Jun 19, 2018 in Java by scarlett
• 1,290 points
+1 vote
4 answers

What is a simple way to repeat a string in java?

There is already answer wriiten using StringBuilder ...READ MORE

answered Dec 16, 2020 in Java by Rajiv
• 8,880 points
0 votes
1 answer

What is Enum in Java?

 It means that the type argument for ...READ MORE

answered Nov 13, 2018 in Java by Frankie
• 9,810 points