What is coercion in Polymorphism?

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

recategorized Jan 31, 2019 by Neha 357 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.

https://www.geeksforgeeks.org/ad-hoc-inclusion-parametric-coercion-polymorphisms/
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,190 points
1,398 views
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,090 points
1,193 views
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
• 50,480 points
301 views
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
• 50,480 points
225 views
+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
2,064 views
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,890 points
2,657 views
+9 votes
12 answers

Default parameters of XMS and XMX in JVM

You use these Java command-line parameters to ...READ MORE

answered Nov 13, 2018 in Java by Murali
188,331 views
0 votes
1 answer
+1 vote
1 answer

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

From Java 11 on, there's a method String::repeat that does ...READ MORE

answered Aug 28, 2018 in Java by Frankie
• 9,810 points
5,105 views
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
91 views