final class Complex {
private final double re;
private final double im;
public Complex(double re, double im) {
this.re = re;
this.im = im;
}
public String toString() {
return \"(\" + re + \" + \" + im + \"i)\";
}
}
class Main {
public static void main(String args[])
{
Complex c = new Complex(10, 15);
System.out.println(\"Complex number is \" + c);
}
}
(A)
Complex number is (10.0 + 15.0i)
(B)
(C)
Complex number is SOME_GARBAGE
(D)
Complex number is Complex@8e2fb5Here 8e2fb5 is hash code of c
Answer
Please comment below if you find anything wrong in the above post
Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!