What is the output? public class Pair { int i; double d; Pair (int i, double d) { this.i = i * 10; this.d = d; Pair (double d, int i) { this.i = i; this.d = d * 10; Pair pl = new Pair (2, 4);...

in this example we have two constructors with the same arguments which is going to confuse the compiler which constructor to call when we call it in main code by an object what is the solution for this problem without changing the number of the arguments in the constructors
What is the output?<br>public class Pair { int i;<br>double d;<br>Pair (int i, double d) { this.i = i * 10;<br>this.d = d;<br>Pair (double d, int i) { this.i = i;<br>this.d = d * 10;<br>Pair pl = new Pair (2, 4);<br>System.out. println (pl.d);<br>

Extracted text: What is the output? public class Pair { int i; double d; Pair (int i, double d) { this.i = i * 10; this.d = d; Pair (double d, int i) { this.i = i; this.d = d * 10; Pair pl = new Pair (2, 4); System.out. println (pl.d);

Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here