When a child class extends a parent class it is called inheritance. A child class can access class members that are present in parent class. If we have many methods that are common between various classes we can define them in a parent class and all child classes can extend the parent class.t Below things to note for inheritace are below
1.if there is a constructor with arguments for parent class then we have to either make a default contructor in parent class with no arguments or make a constructor for child class and the first line in that constructor should make call to the parametrised constructor of parent class
If there is a function with same name in parent class and child class then by default calling that function will call the method of child class itself.To call method of parent class we use keyword super before the function
if there is a method just in parent class but not there in child class we can call it like that without keyword super .It doesn't matter
And if we have a animal reference like this Dog d1 = new Dog(); and then we use methods like d1.eat() it will call eat method in child class if there is one over riden otherwise it will simply call eat in parent class.
this and super .this is used to call another constructor from a constructor in same class.this should be the first line of code in a constructor when calling a constructor from another constructor. same way we can use super to call constructor of parent class ,but again it should be first line of code in child constructor defination.
And a constructor can call either this or super in its defination but not both as it has to be first line in constructor
Now an important scenario arrives in which we want to call a constructor in the child class using this ,but parent class has a paramterised constructor so we need to call that one as well to avoid compile time errors.We we can do in this case is call the other constructor using this keyword and then in the called constructor we can call the super constructor on the very first line