Q:

stackoverflow while calling method of parent class in subclass

I am trying to call the parent method in subclass. But I am getting stackoverflow error. The method name in both the class is same. If I change the method name it doesn't gives error. I am not understanding what is the reason behind it. Below is the code where I am calling display() method, in both the class which gives me stackoverflow error. If I change the name of method in any of one class it doesn't gives me error.
class inherit1 {

int i;
int j;
int k;

public inherit1() {
}

inherit1(int i, int j, int k) {
    this.i = i;
    this.j = j;
    this.k = k;
}
void display() {
    System.out.println("i=" + i + "j=" + j + "k=" + k);
}

}
class in1 extends inherit1 {

int l;

in1() {
}

public in1(int i, int j, int k, int l) {
    super(i, j, k);
    this.l = l;
}

void display() {
    display();
    System.out.println("l=" + l);
}

public static void main(String[] args) {
    in1 i = new in1(12, 12, 12, 12);

    i.display();
}

}

A:

Change
void display() {
    super.display();
    System.out.println("k=" + k);
}

when you are calling display() it calls same child method againg and again causing stackoverflow.Instead you should use super keyword to reference parent method.

