What is output of following JAVA code?
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);
}
}
1
Compiler Error
2
Complex number is Complex@8e2fb5
Here 8e2fb5 is hash code of c
Here 8e2fb5 is hash code of c
3
Complex number is SOME_GARBAGE
4
Complex number is (10.0 + 15.0i)
5
Question Not Attempted