Q:

Calling constructor from subclass

I am new to java and I having problem with my code.I am trying to call a constructor of superclass from subclass's constructor.Although I can do it by super,but I am trying to do with other method by making a object of superclass in subclass's constructor that will call Class A constructor.
class A
{
    private int x;

    A()
    {
        System.out.println("INISDE A");
    }

    A(int h)
    {
        System.out.println("a");
        x = h;
    }
}

class B extends A
{
    int g, add;

    B(int j, int h)
    {
        A a = new A(h);
        g = j;
        add = g + h;
    }

    void add()
    {
        System.out.println("SUM" + add);
    }
}

public class Ja
{
    public static void main(String[] args) {
        // TODO code application logic here
        B v = new B(1, 2);
        v.add();
    }
}

The problem is I am getting output 
INISDE A
a
SUM3

Instead of 
a
SUM3

It means that it is also using the A() .But why? I have given parameters to it 

A:

This:
B(int j,int h) {
   A a=new A (h);
   g=j;
   add=g+h;    
}

instantiates the superclass via A() and then creates a new instance of A (using the single-argument constructor) separate to that underlying B. I suspect you really want:
B(int j,int h) {
   super(h);
   g=j;
   add=g+h;    
}

to instantiate your superclass correctly.

A:

To call the superclass constructor you should use super(...).
So your B class constructor must look like this
B(int j,int h) {
  super(h);
  g=j;
  add=g+h;
}

