The problem you stated does not depend on abstract classes but on static and nonstatic contexts. You simply make two different calls to the instance variable.
The first example tries to access id from a static context which is not allowed and you get your error (Cannot make a static reference to the non-static field id).
public static void main(String[] args)
{
System.out.println("ID : " + id);
}
In the second example, you create an instance of your class and from within this instance you are able to access id
. This is a reference from a nonstatic context.
public void testMethod()
{
System.out.println("ID Value : " + id);
}
So you achieve the same for your first example, if you create an instance like in the second and access id
from a nonstatic method..