I am not able to send values to the baseclass constructor

Create default constructor in your base class.

your sub class constructor implicitly calls default constructor of base class.

if you want initialze your base class with sub class elements, you can call super(int, int) from sub class constructor.

In above example you can use as below,

 sub(int y, int z) {
  super(y,z);
    c = y;
    d = z;
}

in this case base class holds same values that passed to sub class.

if you dont call super(int, int) from sub class constructor, internally it calls default constructor of base class as below

sub(int y, int z) {
  super();
    c = y;
    d = z;
}

Leave a Comment