Q:

Extended Queesion on "how to refer subclass variable without declaring that variable in parent class?"

public class Test {
    public static void main(final String[] args) {
    B b = new B();
    System.out.println(b);
    }
}

interface MyInterface<T> {
    int getX();
}

abstract class A implements MyInterface {
    @Override
    public String toString() {
    return String.valueOf(getX());
    }
}

class B extends A, implements MyInterface<C> {
    private static final int X = 10;

    @Override
    public int getX() {
    return X;
    }
}

class C  {
    // This is concrete class some 
}

I am unable to enhance this interface with generic.
It is throwing error either at abstract class or at implementation class.
How do I make it possible? 

A:

public class MyTest2 {
    public static void main(final String[] args) {
    B b = new B();
    System.out.println(b);
    }
}

interface MyInterface<T> {
    int getX();
}

abstract class A<T> implements MyInterface {
    @Override
    public String toString() {
    return String.valueOf(getX());
    }
}

class B extends A<C>  {
    private static final int X = 10;

    @Override
    public int getX() {
    return X;
    }
}

class C  {
    // This is concrete class some
}

