class Complex {
private int real;
private int imaginary;
// Default Constructor
public Complex() {
this.real = 0;
this.imaginary = 0;
// Parameterized Constructor
public Complex(int real, int imaginary) {
this.real = real;
this.imaginary = imaginary;
// Copy Constructor
public Complex(Complex c) {
this.real = c.real;
this.imaginary = c.imaginary;
// Method to add two complex numbers
public Complex add(Complex c) {
return new Complex(this.real + c.real, this.imaginary + c.imaginary);
// Method to display the complex number
public void display() {
System.out.println(real + " + " + imaginary + "i");
public static void main(String[] args) {
Complex c1 = new Complex(3, 4); // Using Parameterized Constructor
Complex c2 = new Complex(5, 6); // Using Parameterized Constructor
Complex c3 = new Complex(); // Using Default Constructor
Complex sum = c1.add(c2); // Performing addition
System.out.println("First Complex Number:");
c1.display();
System.out.println("Second Complex Number:");
c2.display();
System.out.println("Sum of Complex Numbers:");
sum.display();