Default constructor of super class always call in java

Default constructor of super call always call.

package inherintance;
public class India {
    static int _i=0;
    static int _j=0;
    India(int i){
    System.out.println(“India parameter constructor call=”+_j);
    public India() {
          // TODO Auto-generated constructor stub
    System.out.println(“India default constructor call=”+_i);
package inherintance;
public class Dehradun extends India {
Dehradun (int i){
     System.out.println(“Dehradun parameter constructor calli=”+i);
     public static void main(String[] args) {
          Dehradun obj=new Dehradun(4);
        System.out.println(“I value=”+_i);
           Dehradun obj1=new Dehradun();
             System.out.println(“I value=”+_i);
India default constructor call=1
Dehradun parameter constructor call i=4
I value=1
India default constructor call=2
Dehradun defalt constructor call
I value=2


Leave a Reply

Your email address will not be published. Required fields are marked *

− 1 = 6