final class Complex {
private double re, im;
public Complex( double re, double im) {
this .re = re;
this .im = im;
}
Complex(Complex c)
{
System.out.println( "Copy constructor called" );
re = c.re;
im = c.im;
}
public String toString() {
return "(" + re + " + " + im + "i)" ;
}
}
class Main {
public static void main(String[] args) {
Complex c1 = new Complex( 10 , 15 );
Complex c2 = new Complex(c1);
Complex c3 = c1;
System.out.println(c2);
}
}
|
(A)
Copy constructor called
(10.0 + 15.0i)
(B)
Copy constructor called
(0.0 + 0.0i)
(C)
(10.0 + 15.0i)
(D)
(0.0 + 0.0i)
Answer: (A)
Explanation:
Quiz of this Question
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
28 Jun, 2021
Like Article
Save Article