You need to instantiate an object to call upon.
e.g.
Three t = new Three();
t.outPrint();
The main()
method you'd defined is static and doesn't have an instance of an object (One
/Two
/Three
). It's merely existing in a particular namespace.
Note that you can demonstrate that Three
is-a One
thus:
One t = new Three();
t.outPrint();
and if you override the outPrint()
method for each subclass you can see which method is called depending on how you instantiate and/or refer to the original object instance.